![](/img/trans.png)
[英]Can Not Send Notification to iOS (iPhone) Firebase Cloud Messaging
[英]Not able to send an iOS CriticalAlert to Firebase Cloud Messaging
我有一個內部應用程序,其中在我的應用程序中設置了criticalAlert 選項。 我已經確認,當我使用 pushy 應用程序發送以下內容時,我能夠讓關鍵警報在 iOS 應用程序上工作。
問題是我們的內部服務器目前僅將通知發送到 Firebase 雲消息傳遞,我無法配置原始推送有效負載以在設備上播放嚴重警報。
這是 Apple 給出的關於推送應該如何看待 APNS的示例:
這是我使用適用於該應用程序的 pushy 應用程序發送的內容:
{
"aps" : {
"content_available": true,
"priority": "high",
"alert" : "Your message Here",
"badge" : 1,
"sound": {
"critical": 1,
"name": "alert.wav",
"volume": 1.0
},
"data": {
"volume": 7,
"time_to_live": 900,
"id": 3618,
"type": "engagement",
"overrideMessage": "Testing oncall for iOS",
"case": "Test Case",
"repeatNumber": 3,
"customer": "Google"
}
}
}
這是我們發送到 FCM 的當前有效負載,它與自定義聲音一起工作,但我們真的希望關鍵警報能夠正常工作,因為推送是用於隨叫隨到的參與:
{
"to": "firebaseToken",
"content_available": true,
"priority": "high",
"isCritical": "true",
"notification": {
"title": "Title in notification",
"body": "Body in notification",
"sound": "alert.wav",
"badge": "1",
"subtitle": "subtitle in notification"
},
"data": {
"volume": 7,
"time_to_live": 900,
"id": 3618,
"type": "engagement",
"overrideMessage": "Testing oncall for iOS",
"case": "Test Case",
"repeatNumber": 3,
"customer": "Google"
}
}
我已經嘗試了大量關於發送到 FCM 的組合,但沒有運氣:
{
"to": "firebaseToken",
"apns": {
"headers": {
"apns-priority": "10"
},
"payload": {
"aps" : {
"sound": {
"critical": 1,
"name": "alert.wav",
"volume": 0.5
},
和
{
"aps" : {
"to": "firebaseToken",
"content_available": true,
"priority": "high",
"alert" : "Your message Here",
"badge" : 1,
"sound": {
"critical": 1,
"name": "alert.wav",
"volume": 0.5
},
和
{
"to": "firebaseToken",
"aps" : {
"sound" : {
"critical": 1,
"name": "alert.wav",
"volume": 1.0
}
},
"notification": {
"badge": "1",
和
{
"to": "firebaseToken",
"isCritical": "true",
"content_available": true,
"notification": {
"badge": "1",
"sound" : {
"critical": 1,
"name": "alert.wav",
"volume": 1.0
},
他們都不允許將聲音詞典傳遞給 FCM。
我在這里也有答案,但它並沒有解決我的問題。 因為我需要 iOS 知道這個推送通知很重要並且讓操作系統處理它而不是我的應用程序。
在回答您的具體問題之前,我建議您盡可能考慮使用Admin SDK而不是 REST API。 SDK 在 Node.js、Java、python、go 和 C# 中可用。 如果您的服務器代碼是用這些語言中的任何一種編寫的,那么使用 FCM 處理發送消息的方法要簡單得多。 SDK 處理重試和其他您必須在代碼中實現的場景。
至於您的問題, 指南中指出特定於平台的字段僅適用於 FCM v1 端點。 要使用 FCM,您的端點將如下所示:
https://fcm.googleapis.com/v1/projects/[your-project-id]/messages:send
您可以在指南中看到這樣的示例。 從代碼段選項卡中選擇 REST 以查看示例。
請注意,您授權發送的方式與 V1 不同。 您可以在指南中找到更多信息。 如果您在 auth 部分遇到問題,我還寫了一篇關於它的博客文章,因為它經常出現。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.