我从Postman发送以下有效载荷:
{
"to" : "serverkey",
"data" : {"score":"5"},
"content_available": true,
"notification" : {
"body": "sample21 "
},
"priority" : "high"
}
并收到错误:
<FIRMessaging/WARNING> FIRMessaging receiving notification in invalid state 2
我根据文档使用content_available,所以我不知道问题是什么?
编辑:添加到用户在评论中提出的方法
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
print("in didReceiveRemoteNotification")
print("%@", userInfo)
DispatchQueue.main.async {
completionHandler(UIBackgroundFetchResult.newData)
}
}
extension AppDelegate : FIRMessagingDelegate {
// Receive data message on iOS 10 devices.
func applicationReceivedRemoteMessage(_ remoteMessage: FIRMessagingRemoteMessage) {
print("in applicationReceivedRemoteMessage")
print("%@", remoteMessage.appData)
}
}