简体   繁体   中英

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?

首先将您的用户ID和设备令牌保存到服务器,一旦您需要聊天,只需使用您的聊天ID和朋友聊天ID调用服务器聊天功能,然后使用您的朋友和设备令牌的聊天ID发送通知。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM