13

I recently signed up to use Firebase and I can't seem to figure out how to push notifications to specific users.

For my use, I guess you can think of it like Facebook. Whenever a user does something, say posts an interesting article for their friends to read, I want all of the user's friends to be notified of that event. So, using Firebase, how would one make it possible to notify only their friends and not everyone? My database stores the conenctions.

Perhaps there is a way to have each user be a node in the Firebase database and each time a notification is sent, The user will constantly check his node, and if something appears, pulls it and then delete it.

The examples on Firebase seems to be sort of basic. I wish there was a user-specific push notification example.

Billy Boldwen
  • 139
  • 1
  • 1
  • 3
  • try to do the that i say here: http://stackoverflow.com/questions/37435750/how-to-send-device-to-device-messages-using-firebase-cloud-messaging/37749863#37749863 After you say me ok. – Paulo Linhares - Packapps Jun 10 '16 at 14:43
  • Here See My Documentation i use it and Work fine for me => [See My Code On Stackoverflow](http://stackoverflow.com/questions/37541259/notification-in-ios-using-new-firebase-messaging-sdk/37783083#37783083) – Sanandiya Vipul Jun 13 '16 at 13:00
  • You can using user's registration id. visit this blog for more details http://codingaffairs.blogspot.com/2016/06/firebase-cloud-messaging-push.html – Developine Jun 20 '16 at 07:59
  • Try this https://istudy.io/android-push-notifications-using-firebase-fcm/ – YasirSE Aug 11 '16 at 05:30

2 Answers2

9

Now Firebase supports Push Notification. 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.

JúlioCézar
  • 447
  • 5
  • 8
  • @JúlioCézarl: From what I understand it's not recommended to send PushNotifications from client to client. Because you need to specify an Authorization:key=API_KEY in the request. This key should be kept safe because it allows to send messages on the behalf of your App, so we should limit access to it to trusted processes. Do you know a safe way to send client-to-client PushNotifications with the Firebase Cloud Messaging ? – GV3 Aug 15 '16 at 11:27
2

There's a good explanation of how you can send notifications to specific users here: How to send an alert message to a special online user with firebase

Basically you need to have each user observe a unique path, and then write data updates to the appropriate path.

Community
  • 1
  • 1
Andrew Lee
  • 10,127
  • 3
  • 46
  • 40
  • Yeah, but does that allow you to send Apple push notifications, which go through even when the app isn't running? – ma11hew28 Nov 08 '14 at 22:50
  • Then you need something more than Firebase, that handles the push notifications. Firebase only works with devices/users that have an active connection. – KungWaz Dec 15 '14 at 09:59
  • Can't we start Firebase client in a service? this way it will work in the background and preserve an active connection? – simo Jan 31 '16 at 12:52