我正在嘗試爲我們的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