我使用 postman 发出 HTTP 请求以向主题发送推送通知,我使用了以下正文信息:
{
"to" : "/topics/mahdi",
"priority" : "high",
"notification" : {
"body" : "This is a Firebase Cloud Messaging Topic Message!",
"title" : "FCM Message2"
}
}
当然我把授权 key 放在header里请求成功得到:
{"message_id":5081280333669625878}
但是我的iOS设备没有收到通知,请问是哪里出错了?
最佳答案
确定你有
- 在功能中激活推送通知
- 在功能中激活后台模式“后台获取”和“远程通知”,以便在后台接收通知。
替换您的 AppDelegate 或将方法修改为 https://github.com/firebase/quickstart-ios/blob/master/messaging/MessagingExampleSwift/AppDelegate.swift说
在 firebase 控制台中,更改Cloud Messaging 设置(项目设置->Cloud Messaging)并上传您的 P12 证书。 (阅读这篇文章以了解如何制作您的 p12 https://stackoverflow.com/a/28962937/4077559 )
编辑:根据https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html , 要使其在后台运行,您还必须在消息中设置以下内容:
"content-available":"1"
关于ios - 通过 postman 发送推送通知 firebase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42245392/