是否可以使用Firebase云消息传递(FCM)直接从设备发送PushNotifications到特殊的UDID? [英] Is it possible to send PushNotifications, using Firebase Cloud Messaging (FCM) to special UDID, directly from device?
问题描述
我正考虑将所有注册ID(推送令牌)保存在数据库中,并将通知从iPhone发送给用户。我试过类似的东西,但没有收到任何通知。
$ b $ pre $ func sendPNMessage(){
FIRMessaging.messaging() .sendMessage(
[body:hey],
to:TOKEN_ID,
withMessageID:1,
timeToLive:108)
}
我做错了或者根本不可能?
您可能想要联系一个服务器(如通过http调用),该服务器将发送消息给用户。
这样可以确保服务器的API-KEY受到保护。
PS: sendMessage(..)
api称为上游功能,如果服务器与FCM服务器具有XMPP连接,则可用于将消息从应用程序发送到服务器。
I am thinking about keeping all registration ids(push token) in DB and sending notifications to user from iPhone. I tried something like this but did not get any notification.
func sendPNMessage() {
FIRMessaging.messaging().sendMessage(
["body": "hey"],
to: TOKEN_ID,
withMessageID: "1",
timeToLive: 108)
}
What I am doing wrong or maybe it is impossible at all?
Currently it's not possible to send messages from the application itself. You can send messages from the Firebase Web Console, or from a custom server using the server-side APIs.
What you might want to do is to contact a server (like via http call) and that server will send the message to the user. This way ensure that the API-KEY of the server is protected.
PS: the sendMessage(..)
api is called upstream feature, and can be used to send messages from your app to your server, if you server has an XMPP connection with the FCM server.
这篇关于是否可以使用Firebase云消息传递(FCM)直接从设备发送PushNotifications到特殊的UDID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!