我已经按照this教程来实现我的目标(即 - Send push notifications
所有用户(设备)包含图片和文字)无论中的应用是什么前景或背景。
我学到了什么,如果我们使用Messaging API(ARC - 高级REST客户端)发送 ,那么用户将获得带有图像和文本的通知,这两个应用都在{ {1}}。
但我不知道如何使用foreground or background
向所有设备/用户发送通知?
我使用以下脚本将通知仅发送给单个用户:
Messaging API (ARC)
如果,我无法使用https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIza************adrTY
{ "data": {
"image": "https://ibin.co/2t1lLdpfS06F.png",
"message": "Firebase Push Message Using API"
"AnotherActivity": "True"
},
"to" : "f25gYF3***********************HLI"
}
向所有用户发送通知,那么我将浪费时间。
答案 0 :(得分:1)
一种方式是将所有用户订阅到一个主题并发送到主题。
像这样:
FirebaseMessaging.getInstance().subscribeToTopic("all");
并发送这样的通知:
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIza************adrTY
{ "data": {
"image": "https://ibin.co/2t1lLdpfS06F.png",
"message": "Firebase Push Message Using API"
"AnotherActivity": "True"
},
"to" : "/topics/all"
}