Is it possible to send PushNotifications, using Firebase Cloud Messaging (FCM) to special UDID, directly from device?(是否可以直接从设备使用 Firebase 云消息传递 (FCM) 将 PushNotifications 发送到特殊的 UDID?)
问题描述
我正在考虑将所有注册 ID(推送令牌)保留在数据库中,并从 iPhone 向用户发送通知.我尝试了类似的方法,但没有收到任何通知.
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?
推荐答案
目前无法从应用程序本身发送消息.您可以从 Firebase Web 控制台发送消息,也可以使用服务器端 API 从自定义服务器发送消息.
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.
您可能想要做的是联系服务器(例如通过 http 调用),该服务器会将消息发送给用户.这样可以确保服务器的 API-KEY 受到保护.
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:sendMessage(..) api 称为上游功能,如果您的服务器与 FCM 服务器有 XMPP 连接,则可用于将消息从您的应用程序发送到您的服务器.
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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否可以直接从设备使用 Firebase 云消息传递 (FCM) 将 PushNotifications 发送到特殊的 UDID?
基础教程推荐
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iOS4 创建后台定时器 2022-01-01
