是否可以使用Firebase云消息传递(FCM)直接从设备发送PushNotifications到特殊的UDID? [英] Is it possible to send PushNotifications, using Firebase Cloud Messaging (FCM) to special UDID, directly from device?

查看:399
本文介绍了是否可以使用Firebase云消息传递(FCM)直接从设备发送PushNotifications到特殊的UDID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正考虑将所有注册ID(推送令牌)保存在数据库中,并将通知从iPhone发送给用户。我试过类似的东西,但没有收到任何通知。
$ b $ pre $ func sendPNMessage(){
FIRMessaging.messaging() .sendMessage(
[body:hey],
to:TOKEN_ID,
withMessageID:1,
timeToLive:108)
}

我做错了或者根本不可能?

您可以使用服务器端API从Firebase Web控制台发送消息,也可以从自定义服务器发送消息。

您可能想要联系一个服务器(如通过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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆