FCM Cordova插件 - 向非订阅用户发送通知

时间:2016-09-28 21:02:00

标签: android firebase firebase-cloud-messaging

我不太了解如何向收到操作的用户发送通知。例如,当User AUser B添加评论等时,我希望User B收到通知。

如果User A添加评论等,我可以向此模式中User A主题中订阅的每位关注者发送通知。关注者主题订阅:

FCMPlugin.subscribeToTopic('topicExample');

我通过User A发送REST API通知:

{
  "notification":{
    "title":"Notification title",  //Any value
    "body":"Notification body",  //Any value
    "sound":"default", //If you want notification sound
    "click_action":"FCM_PLUGIN_ACTIVITY",  //Must be present for Android
    "icon":"fcm_push_icon"  //White icon Android resource
  },
  "data":{
    "param1":"value1",  //Any data to be retrieved in the notification callback
    "param2":"value2"
  },
    "to":"/topics/topicExample", //Topic or single device
    "priority":"high", //If not set, notification won't be delivered on completely closed iOS app
    "restricted_package_name":"" //Optional. Set for application filtering
}

但我不明白如何向User B发送通知,因为他未订阅User A,是否可以仅发送通知订阅某个主题的用户?

0 个答案:

没有答案