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?


基础教程推荐
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01