2

I'm practicing Swift programming by trying to build Instagram for fun. I am using firebase as my database. I was able to set up the activity page where it shows a user has liked/commented on your post.

Now I am wondering how can I actually send a push notification when that happens? I tried using FirebaseMessaging but all I can really do is send messages from firebase directly.

How do I send a specific user a push notification that someone has liked their post?

KENdi
  • 7,576
  • 2
  • 16
  • 31
  • you can with firebase functions see this example https://github.com/firebase/functions-samples/tree/master/fcm-notifications – mohamad rabee Aug 08 '17 at 23:27
  • Hi, Welcome to stack overflow. Please refer the [How to Ask](https://stackoverflow.com/help/how-to-ask) link for more details on how to ask a question and update your question accordingly. – Govind Samrow Aug 09 '17 at 04:57

2 Answers2

0

You can try using Firebase functions. Here are the basic concepts:

  1. To receive notifications, user must subscribe to a "topic" using subscribeToTopic(String topic)
  2. Whenever a post from that topic is created, you use firebase messaging to send message to that topic
  3. To do that, you need to host a function to firebase. That function listens to new posts being posted at whatever node you are using
  4. Everytime a new post is written to that node, it sends the message

Here is the link to the of an example Firebase Functions Example (the function to be hosted is sendNotificationToLocation).

Check this on how to handle subscribing/unsubscribing and handling message/notification Firebase messaging

Kim G Pham
  • 145
  • 6
0
  1. First do the all configurations for Firebase Cloud Messaging.
  2. Then get firebase registration token of the user whom you want to send a push notifications to.
  3. follow this link for detailed explanation
Timchang Wuyep
  • 629
  • 7
  • 10