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

本文介绍了是否可以使用 Firebase 云消息传递 (FCM) 直接从设备向特殊 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) 直接从设备向特殊 UDID 发送推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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