我正在尝试为我们的iOS应用程序接收“数据”有效负载通知。如果发送“数据”(但是“通知”有效)有效载荷到iOS中的GCM/FCM,则不会收到推送通知didReceiveRemoteNotification
今天,我们可以发送GCM notification
推送通知为依据:
https://developers.google.com/cloud-messaging/concept-options
(FCM具有相同的文字)
一个简单的测试是使用curl:
curl -X POST \
https://gcm-http.googleapis.com/gcm/send \
-H 'authorization: key=##_GCM_SERVER_ID_##' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'postman-token: ##_POSTMAN_TOKEN_##' \
-d '{
"notification": {
"body": "Test body"
},
"to" : "##_DEVICE_TOKEN_##"
}
'
这将成功触发iOS AppDelegate.didReceiveRemoteNotification:fetchCompletionHandler
功能。
但是,如果将其更改为data
通知:
curl -X POST \
https://gcm-http.googleapis.com/gcm/send \
-H 'authorization: key=##_GCM_SERVER_ID_##' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'postman-token: ##_POSTMAN_TOKEN_##' \
-d '{
"data": {
"body": "Test body"
},
"to" : "##_DEVICE_TOKEN_##"
}
'
我什么都看不到被发送到应用程序从GCM(任didReceiveRemoteNotification
功能),即使该应用程序在后台/前景。
https://developers.google.com/cloud-messaging/concept-options#notifications_and_data_messages
注意这些进一步的特定平台的细节:
即使它的文档就应该在说
- 在Android上,数据有效载荷可以在Intent检索用于启动您的活动。
- 在iOS上,数据有效载荷将在didReceiveRemoteNotification:中找到。
GCM可以处理纯data
推送通知的APN网络吗?
我需要做什么特别的事情才能收到data
,与notification
相比,推送通知在iOS?
也许由于这个https://开头计算器的.com /一个/80389分之36019064 – corgrath