user8637139
user8637139

Reputation: 43

iOS push notification using Firebase FCM tokens

Here’s a question which is more about what’s the industry standard way of sending iOS push notifications using Firebase FCM token. I don’t have my own push server so would like to utilize Firebase cloud function. I am building an app which has chat feature and I want to notify the user as soon as they get a new message. In Firebase cloud function I have a piece of code running there with a hard coded fcm token, which successfully sends notification to my device when I invoke the url to that cloud function. Now in case of multiple users chatting with each other, how do I pass the fcm token to the cloud function? One way is - as soon as I send a messages to my chat friend, my app could invoke that url and pass my chat friends fcm token to the cloud function, which would trigger notification to the chat friend. As soon as cloud function receives this trigger, I could also fetch friends profile, and update badge count etc for the notification. But in this case responsibility lies on my app and not the server to send the trigger. Is there any other better way to design notification functionality and how should I store and fetch device tokens server side?

Upvotes: 2

Views: 982

Answers (1)

Shivshankar
Shivshankar

Reputation: 50

Firstly save your user id and device token to the server, Once you have to chat just call server chat function with your chat id and the friend chat id then send a notification using the chat id of your friend and device token.

Upvotes: 1

Related Questions