簡體   English   中英

使用離子推送的多個推送通知

[英]Multiple push notifications using ionic push

發送兩個通知時,第二個通知始終會覆蓋通知中心中的第一個通知。 根據文檔,這應該僅在使用標記時發生:

“標簽”:指示每個通知消息是否會在通知中心上產生一個新條目。 如果未設置,則每個請求都會創建一個新通知。 如果已設置,並且已經顯示具有相同標簽的通知,則新通知將替換現有通知。

但是,無論我是否為標簽設置值,這種情況一直在我身上發生。

我什至嘗試設置一個隨機標簽和crash_key(據我所知,在這種情況下不應該將其關聯,但我嘗試了一下)。 仍然沒有幫助。 這是我要發送的通知對象的示例:

{  
   "tokens":[  
      "my-device-token"
   ],
   "profile":"my-profile-tag",
   "notification":{  
      "message":"message",
      "android":{  
         "payload":{  
            "collapse_key":9918519,
            "tag":2825928
         }
      }
   }
}

我解決了這個問題。 您需要在“ android”的“ data”中添加“ notId”。 例:

"notification": {
    "title": "testing stack notification ",
    "message":"is it working",
    "android": {               
        "data": {
            "title": "testing stack notification",
            "message": "is it working",
            "style": "inbox",
            "summaryText": "yes its %n% notifications",
            "notId": "123456"
        }
    }
}

您需要在對象中指定一個唯一的通知ID(例如,unix時間戳),以免覆蓋前一個-在您的情況下:

{  
   "tokens":[  
      "my-device-token"
   ],
   "profile":"my-profile-tag",
   "notification":{  
      "notId": <some-unique-value-here>,
      "message":"message",
      "android":{  
         "payload":{  
            "collapse_key":9918519,
            "tag":2825928
         }
      }
   }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM