How to send a push notification from the Firebase console to a specific GCM/FCM device token ID

泄露秘密 提交于 2020-03-13 14:00:05

问题


In Urban Airship, when I am composing a notification, I can target specific users by searching for a Urban Airship channel_id (device ID):

I sent from Urban Airship the push notification that I am showing above, and I received it successfully. Now I want to do the same thing, send a push notification to a specific device, but now using the Firebase console. The problem is that in Firebase, in the step where I need to specify the target, it only allows me to choose User segment or topic. I was expecting to see a third option: Target specific users (for sending notifications to one or many specific GCM/FCM device token IDs. So my alternative is to add a GCM/FCM device token ID to a topic and then send the push notification to that topic, which is something that I have successfully done before. Nonetheless, that would be a workaround and not the way I would prefer to do this. Is it possible to send push notifications to specific users (by defining the target GCM/FCM device token IDs) from the Firebase console? Thank you.

UPDATE 1: See how the Firebase console (https://console.firebase.google.com/) only shows User segment and Topic as the Target:


回答1:


By design, the notification feature in the console is for sending out broadcast-type events. Sending user-specific alerts would be more of a programmatic operation done through the API.

For sending test messages, there is a console tool for this, explained here.

Note that it is possible to send a notification to one device by subscribing a device to any topic and sending the notification to that topic in the console (keep in mind topics are public and you can't prevent users from signing up to them; fine for testing most likely).

Another alternative is to send a message via HTTP or curl. Perhaps the best resource for this is the quickstart/messaging example.




回答2:


First Step:

Second Step:

Third Step:



来源:https://stackoverflow.com/questions/56199392/how-to-send-a-push-notification-from-the-firebase-console-to-a-specific-gcm-fcm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!