1

I am planning to implement notifications in my Angular 4 web app using Google Firebase. Every user in my application will have his own set of notifications. I have seen that Firebase can broadcast the messages to a user group or to the subscribers of a topic. But, is there any way to send customized notifications to independent users? If I have to use Pub-Sub pattern, is it a right approach to create a topic for every user id and push notifications to those topics?

Thanks in advance.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Phani Mahesh
  • 85
  • 1
  • 13
  • Are you sending messages programmatically from a backend or using the Notifications composer in the Firebase console? – Doug Stevenson Oct 24 '17 at 04:20
  • I am planning to log events in the database and based on the event, the user affected by that event should be notified with some custom message programmatically. – Phani Mahesh Oct 24 '17 at 15:40

1 Answers1

3

When you use Firebase Cloud Messaging in an app (Web, Android, or iOS) it gets a unique Instance ID (also often called a Device Registration Token). This Instance ID can be used to unique identify that specific app on that specific device.

If you want to send a message to that specific app on that specific device, you can send a message to the Instance ID as shown here.

If a user uses the same app on multiple devices, and you want to send a message to the user on all devices, you'll typically combine the Instance IDs into a so-called device group as shown here.

Finally, if you want to send a message to a group of users who have all subscribed to a specific topic, you can send the message to that pub/sub topic as shown here.

Given your description it sounds like you're looking to either send to the Instance ID or to a device group.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thank you for the response. My web application is a portal where every user has his own account. For example, when I logged into my Stack Overflow account I have seen a notification when you have responded to my question. This notification is specific to me. I am trying to achieve something like this using Firebase. I am planning to log events in the database and based on the event, the user affected by that event should be notified with some custom message. – Phani Mahesh Oct 24 '17 at 15:40
  • All sounds feasible. I wrote a blog post a while ago that used topics to accomplish user-targeted messages: https://firebase.googleblog.com/2016/08/sending-notifications-between-android.html – Frank van Puffelen Oct 24 '17 at 16:11
  • Awesome! Thank you, it makes sense. I have learned that these notifications are not fit for IOS - as they don't support service workers. Do we have any alternative for IOS devices? FYI - I am not building a native application, it is just a responsive web app. – Phani Mahesh Oct 25 '17 at 01:53
  • I'm not aware of any push notification technology for web apps on iOS. – Frank van Puffelen Oct 25 '17 at 03:41