![](/img/trans.png)
[英]Cordova Firebase Plugin - Not showing notifications in notification bar on iOS
[英]cordova, Firebase, FCM Plugin - Not showing notifications in notification bar on iOS
我正在使用這個帶有cordova 的插件 : cordova-plugin-fcm來獲取通知。
它適用於Android。
問題出在iOS上,當應用程序處於前台時,通知會到達。 但是當應用程序關閉或在后台時,通知不會顯示在通知欄中,但是當我打開應用程序時,我可以看到通知到達並且我生成的彈出窗口被打開。
但我真的需要通知在鎖定屏幕和通知欄中顯示。
這是我發送給Firebase API的內容:
/ POST to https://fcm.googleapis.com/fcm/send
而在身體我發送這個:
{
"to" : <USER_TOKEN>,
"alert":"Test",
"notification": {
"alert":"Test test",
"title": "Notification test",
"text": "Testing notification text"
},
"priority": 10,
"content_available": true
}
我也嘗試過"priority": "high"
並獲得相同的結果。
通知到了,但它只在我打開應用程序時顯示。 我甚至沒有在通知欄或鎖屏中看到它。
此外,我嘗試在正文中添加"aps"
屬性,里面的所有信息都不起作用。
我希望有人可以對此有所啟發..
PS: iOS v10.1.1
PS2:適用於所有Android設備。
我已經從社區中讀到了一些答案,但似乎沒有用:
謝謝你的時間。
你有沒有在console.firebase.google.com上傳你的開發APNs證書,
將您的APNs證書上傳到Firebase。 如果您還沒有APNs證書,請參閱配置APNs SSL證書。
在Firebase控制台的項目內,選擇齒輪圖標,選擇“項目設置”,然后選擇“雲消息傳遞”選項卡。 選擇開發證書,生產證書或兩者的“上載證書”按鈕。 至少需要一個。 對於每個證書,請選擇.p12文件,並提供密碼(如果有)。 確保此證書的軟件包ID與應用程序的軟件包ID相匹配。 選擇保存。
您可以參考鏈接https://firebase.google.com/docs/cloud-messaging/ios/client
我有同樣的問題,首先,你需要使用“body”而不是“text”; 對於優先級,您應始終使用“高”或“正常”,對於推送,默認值應該高。 如果您忘記在Json字符串的通知對象中使用“title”和“body”鍵,iOS顯然不會將通知添加到notificatios列表中。
如果需要某些自定義值,請添加具有自定義值的數據對象。 像這樣:
"data":{
"data1":"value1",
"data2":"value2"
}
所以嘗試這樣的事情:
{
"to" : <USER_TOKEN>, //or /topics/<topicname> or /topics/all"
"notification": {
"title": "Notification test",
"body": "Testing notification text"
},
"priority": high,
"sound":"default", //not using this one wont make your iOS device use sound
"click_action":"FCM_PLUGIN_ACTIVITY",
"icon":"fcm_push_icon"
}
結合數據對象:
{
"to" : <USER_TOKEN>, //or /topics/<topicname> or /topics/all"
"notification": {
"title": "Notification test",
"body": "Testing notification text"
},
"data":{
"data1":"value1",
"data2":"value2"
},
"priority": high,
"sound":"default", //not using this one wont make your iOS device use sound
"click_action":"FCM_PLUGIN_ACTIVITY",
"icon":"fcm_push_icon"
}
我希望這有幫助,它對我有用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.