Svi*_*ana 16 ios firebase google-cloud-messaging firebase-cloud-messaging firebase-notifications
我正在考虑在数据库中保留所有注册ID(推送令牌)并从iPhone发送通知给用户.我试过这样的事情,但没有得到任何通知.
func sendPNMessage() {
FIRMessaging.messaging().sendMessage(
["body": "hey"],
to: TOKEN_ID,
withMessageID: "1",
timeToLive: 108)
}
Run Code Online (Sandbox Code Playgroud)
我做错了什么或者根本不可能做到这一点?
Die*_*ini 19
目前,无法从应用程序本身发送消息.您可以使用服务器端API从Firebase Web控制台或自定义服务器发送消息.
您可能想要做的是联系服务器(如通过http调用),该服务器将消息发送给用户.这样可以确保服务器的API-KEY受到保护.
PS:sendMessage(..)
api称为上游功能,如果服务器与FCM服务器有XMPP连接,则可用于将消息从应用程序发送到服务器.
是的,您可以通过Firebase发送推送通知.请确保不要将服务器密钥包含在您的客户端中.有些方法"不是那么好的人"找到它并做些事情......正确的方法是让你的客户指示你的app-server发送通知.
您必须将HTTP-Post发送到Google-API-Endpoint.
您需要以下标题:
Content-Type: application/json
Authorization: key={your_server_key}
You can obtain your server key within in the Firebase-Project.
HTTP-Post-Content: Sample
{
"notification": {
"title": "Notification Title",
"text": "The Text of the notification."
},
"project_id": "<your firebase-project-id",
"to":"the specific client-device-id"
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4883 次 |
最近记录: |