Best way to implement push notifications with Fire

2020-02-19 11:11发布

I am an iPhone app coder, and I'm using Firebase as my backend server. Firebase doesn't support Push Notifications, so I've been trying to figure out how to include them in my app. I've read this question: How to send an alert message to a special online user with firebase but it seems like more of a work-around than an actual solution.

Is there an answer on how to do this? Are there third parties or APIs that might seemlessly implement this functionality?

One solution I have tried is to use Zapier to connect Firebase to Pushover.

At this point, I've been able to observe events in the app that I'm coding and then get notifications in a pushover app on my iphone. However, ideally, I'd like to receive the notifications in my app, not in the pushover app, because I don't want users to need to have pushover in order to use my app and because I want users to receive their own distinct notifications, not notifications for everyone.

Does anyone have suggestions on how I should handle this issue?

Thanks for the help!

EDIT This isn't a duplicate of this question: Does firebase handle push notifications? because I know Firebase doesn't directly handle push notifications. I'm looking for the best indirect way of handling push notifications with Firebase.

7条回答
forever°为你锁心
2楼-- · 2020-02-19 11:25

Just realized that they've come out this:

Batch

查看更多
看我几分像从前
3楼-- · 2020-02-19 11:33

Here's the answer I got from the Firebase team:

Firebase currently does not have push notification feature. You can use Firebase Queue and GCM to implement push notification in your app. Queues can be used in your Firebase app to organize workers or perform background work like generating thumbnails of images, filtering message contents and censoring data, or fanning data out to multiple locations in your Firebase database. Google Cloud Messaging (GCM) is a free service that enables developers to send messages between servers and client apps and it is available in both iOS and Android.

You can push an object with some data to the /queue/tasks location in your Firebase using any Firebase client or the REST API. Workers listening at that location will automatically pick up and process the job. From that, your workers can make a GCM push notification.

(end of message from Firebase team)

~~~~~~~~~

Here's my analysis:

It seems like there are a few solutions, but the two best ones are:

1) Use FirebaseQueue with Google Cloud Messaging.

2) Leverage the Push Notification functionality in Parse within the Firebase app.

I'm not sure which is better. Parse seems more proven, but Firebase Queue is more-easily integrated into the app (ie. it's nice have everything on Firebase and not having to set up a Parse app)

Anyways, I hope this thread helps out other people!

查看更多
淡お忘
4楼-- · 2020-02-19 11:34

Now Google rebranded GCM to Firebase Cloud Messaging and it now offers this cross platform service. Firebase also offers notifications.

These are the differences between these two services:

Firebase Cloud Messaging provides a complete set of messaging capabilities through its client SDKs and HTTP and XMPP server protocols. For deployments with more complex messaging requirements, FCM is the right choice.

Firebase Notifications is a lightweight, serverless messaging solution built on Firebase Cloud Messaging. With a user-friendly graphical console and reduced coding requirements, Firebase Notifications lets users easily send messages to reengage and retain users, foster app growth, and support marketing campaigns.

If you want a more detailed comparison. Read this.

查看更多
三岁会撩人
5楼-- · 2020-02-19 11:39

There are a couple of options: (well, more than a couple but here's two)

Parse handles push notifications very very well - they have that down pat and it's super simple. However, you may have issues with users and accounts - depending on what your app does.

You mentioned Pushover. We worked their API a while back but not through Zapier. If I remember correctly, I believe you can simply register your app, send an HTTPS: request to their server and then the notifications are sent from/to your app.

Also, you may want to evaluate how you are using push as it's possible you can roll a notification-like event just into the app itself.

查看更多
放荡不羁爱自由
6楼-- · 2020-02-19 11:39

I had the same problem and managed to figure out a solution a while back. I have detailed my solution in the following posts https://stackoverflow.com/a/44192515/7048719 and https://stackoverflow.com/a/42240984/7048719

You have to create a firebase data service class and use a shared instance to hold the observers in memory when the app goes into background. From there it is just a matter doing what you wish.

查看更多
该账号已被封号
7楼-- · 2020-02-19 11:40

If you want device to device push messages and not just server to device, the only solution I found was OneSignal. I was able to add basic device to device push message support for my app in about an hour and it is currently free.

Both Batch and Firebase only support server to device push messages, not what you want for a chat app

查看更多
登录 后发表回答