12

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.

Community
  • 1
  • 1
Philip Sopher
  • 627
  • 2
  • 8
  • 19
  • Possible duplicate of [Does firebase handle push notifications?](http://stackoverflow.com/questions/25078953/does-firebase-handle-push-notifications) – Pipiks Jan 07 '16 at 17:03
  • 1
    No, this isn't a duplication because I know Firebase doesn't directly handle push notifications. I'm looking for ways to do push notifications even though Firebase doesn't handle them directly. @Pipiks – Philip Sopher Jan 07 '16 at 17:05
  • 2
    Actually, as of today (May 19 2016) Google just rebranded GCM to Firebase Cloud Messaging and it offers this feature. See [this](http://stackoverflow.com/a/37336674/3032209) response for a more complete answer. – Yair Kukielka May 20 '16 at 01:54
  • See here My Demo => [Demo Code here on Stackoverflow](http://stackoverflow.com/questions/37541259/notification-in-ios-using-new-firebase-messaging-sdk/37783083#37783083) – Sanandiya Vipul Jun 13 '16 at 13:02
  • See here My Demo => [Demo Code here on Stackoverflow](http://stackoverflow.com/questions/37541259/notification-in-ios-using-new-firebase-messaging-sdk/37783083#37783083) – Sanandiya Vipul Jun 13 '16 at 13:02
  • this is for android. but you will get idea how it works. http://codingaffairs.blogspot.com/2016/06/firebase-cloud-messaging-push.html – Developine Jun 20 '16 at 08:02

7 Answers7

13

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.

onmyway133
  • 45,645
  • 31
  • 257
  • 263
JúlioCézar
  • 447
  • 5
  • 8
7

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

n6xej
  • 461
  • 5
  • 15
  • **Batch supports client-side push notifications** as well by using the [Transactional API](https://batch.com/doc/api/transactional.html) directly from app code. Basic example with our [Swift client](https://gist.github.com/abarisain/91ff0812e65cfcb85b3a9195a0f76622). – Antoine Guénard Jul 14 '16 at 17:59
  • 1
    I did not conclude from the Transactional API description that it was supported: "The Batch transactional API is a RESTful API that lets you to send notifications from your own systems to specific users, based on their device token or your own user ids" I thought your own systems were your servers to run the campaign. Furthermore, you need to be a Premium, Pro, or Enterprise users: "The transactional API allows you to target up to 10,000 push tokens and is available for Premium, Pro and Enterprise users" – n6xej Jul 14 '16 at 22:23
  • As soon as you have access to an open API, you can call it from wherever you want (server-side code or client-side code), it's valid for Batch and all other push notification providers. – Antoine Guénard Jul 15 '16 at 09:14
  • Hi @n6xej, can you please point me to any documentations which shows on how to use device to device push messages using the OneSignal? I am not finding any such documentations. Thanks. – Rajan Maharjan Oct 24 '16 at 12:02
2

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.

gregschlom
  • 4,825
  • 4
  • 28
  • 23
Jay
  • 34,438
  • 18
  • 52
  • 81
  • Thanks @Jay, a solution that I've been looking into is using node.js to listen for changes to specific Firebase directories like this question suggests: http://stackoverflow.com/questions/28686138/firebase-push-notifications-node-worker but it's difficult to learn how to implement this. Are there examples that you've seen? – Philip Sopher Jan 07 '16 at 20:40
  • Hi @PhilipSopher, I just implemented a Parse and Firebase setup -- I don't have the example online yet, but can help with any specific questions. Like you mentioned, you can have a node.js server listen for changes on the Firebase data. In Parse, you associate a user's installation (containing their device token) to a firebase user (e.g., with a uid). Once the firebase data that you're listening to changes, your node.js server receives the a child_added event from Firebase and you can look up the associated user in Parse – liampronan Jan 08 '16 at 03:29
  • @liampronan are you using Parse just for sending push notifications, or does it have other uses in your app? I'd love to see the code example when you have it online! – Philip Sopher Jan 08 '16 at 16:24
  • I don't know if leveraging node.js is really necessary. Your app will receive events from Firebase and when it receives one that should be pushed, just sent it to Parse for the client push notifications. It's a pretty simple setup other than handling the user aspect - determining which is better for user Auth; Parse or Firebase. – Jay Jan 08 '16 at 18:47
  • @liampronan how do you, as you say, associate a Parse user's installation to a Firebase user? Does that have to be done during login? The other step I'm confused about is how to create a node.js listener. Thanks again for the help! – Philip Sopher Jan 08 '16 at 18:50
  • @Jay as you say, handling the user aspect seems complex! Do you have a code sample for how to do this? Where in the code do you do it? When a user logs in? Thanks for the help! – Philip Sopher Jan 08 '16 at 18:51
  • A quick solution is create two sets of users, one in Parse, one in Firebase. When you add a user to Parse, also add it to Firebase. You could also just forget that completely and use use Firebase for Authentication and leverage Parse just for the Push notifications. If you have not coded up an app in Parse yet, it's pretty darn good and worth the time to experiment - you could slap together a basic app in probably 20 minutes to see how they use Push Notifications. – Jay Jan 08 '16 at 19:00
  • Using Firebase for authentication and leveraging Parse just for Push notifications is what I'm trying to do. Do you have any sample code or resources for how to that. I'm sure it's easy, I just haven't been able to figure it out! Thanks again @Jay! – Philip Sopher Jan 08 '16 at 19:04
  • Parse has a snappy iOS Push Tutorial! Create a free parse account and download the code! – Jay Jan 08 '16 at 19:46
  • Agree with @Jay on most points -- check the docs and experiment! Though I'd strongly suggest against client push: it's inherently insecure and very easy to exploit. Probably fine for a trial app, but not good for production. See here for more: http://blog.parse.com/learn/engineering/the-dangerous-world-of-client-push/ – liampronan Jan 08 '16 at 20:38
1

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!

Philip Sopher
  • 627
  • 2
  • 8
  • 19
  • 1
    Three things: If my answer helped you, please accept it! Don't post an answer to your own question - edit your question with additional info or edit the answer, or post a comment. You *really* need to go through the Parse Notifications app example. It's super easy and can be integrated into your app with very little time and effort. Glad we could help! – Jay Jan 09 '16 at 14:48
  • Thanks @Jay for the help! I'm new to stackoverflow and don't fully understand the decorum. I just liked your post, but I'm going to leave the second answer, just because it often helps me to read through many different answers instead of just one. But again, thanks for your help. I've gone through the Parse example, and it was very helpful! – Philip Sopher Jan 09 '16 at 16:29
1

Just realized that they've come out this:

Batch

felixwcf
  • 2,078
  • 1
  • 28
  • 45
1

Firebase now has Notifications inbuilt. https://firebase.google.com/docs/notifications/

Dipesh
  • 379
  • 3
  • 10
0

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.

Abishek Gokal
  • 186
  • 2
  • 13