我有兩個不同的通知。
其中一條是消息,另一條是通知其他內容。
我想分開通知。
例如,當我收到通知消息並點擊它時,會打開聊天室,而另一個會打開另一個活動。如何在Android上分開FCM通知?
0
A
回答
4
以下是發送下行消息所需的一些基本屬性。
到 - 類型字符串 - (可選)[消息的接收者] 該值必須是一個單個註冊令牌,通知鍵,或主題。類型字符串數組 - - (可選)[消息的接收者] 多個註冊標記,分1最大值1000
優先發送到多個主題
registration_ids當不設置這個字段- 類型字符串 - (可選)[默認正常] 允許的值爲normal和high。
delay_while_idle- 類型布爾 - (可選)[默認值假] true表示直到設備變爲活動的消息不應被髮送。
time_to_live- 類型JSON數 - (可選)[默認值4周最多4周] 此參數指定消息應該多長時間(以秒爲單位)被保持在FCM存儲如果該設備是離線
數據- 類型JSON對象 指定消息有效負載的自定義鍵值對。 例如。{「POST_ID」:」 1234「,」 POST_TITLE」:」博客文章標題」}
在Android中你會接受她在onMessageReceived()作爲地圖數據...
public class FcmMessageService extends FirebaseMessagingService{
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
//onMessageReceived will be called when ever you receive new message from server.. (app in background and foreground)
Log.d("FCM", "From: " + remoteMessage.getFrom());
if(remoteMessage.getNotification()!=null){
Log.d("FCM", "Notification Message Body: " + remoteMessage.getNotification().getBody());
}
if(remoteMessage.getData().containsKey("post_id") && remoteMessage.getData().containsKey("post_title")){
Log.d("Post ID",remoteMessage.getData().get("post_id").toString());
Log.d("Post Title",remoteMessage.getData().get("post_title").toString());
// eg. Server Send Structure data:{"post_id":"12345","post_title":"A Blog Post"}
}
}
}
0
爲此,您應該使用click_action字段,該字段允許您指定用戶點擊通知時要啓動的活動。
所以在您的通知有效載荷:
click_action: "<intent to launch>"
如果沒有定義,則click_action默認爲啓動意向書/活動。
相關問題
- 1. IONIC android FCM通知
- 2. FCM通知爲Android
- 3. Fcm通知push android/IOS nodejs
- 4. Android推送通知,fcm
- 5. Android FCM通知問題
- 6. 如何添加fcm通知?
- 7. 在FCM通知點擊Android後打開活動
- 8. FCM推送通知
- 9. FCM擡頭通知
- 10. FCM通知問題
- 11. MobileFirst 7.1.0 Android FCM推送通知
- 12. FCM背景通知問題android
- 13. Android - Azure推送通知Google FCM
- 14. Android推送通知的FCM限制?
- 15. 使用FCM向Android推送通知(c#)
- 16. Android FCM顯示觸發服務通知
- 17. 從fcm獲取舊通知Android
- 18. Android的FCM - 禁用/啓用通知
- 19. Android通知FCM vs簡單拉
- 20. 發送通知到Android使用FCM
- 21. C#FCM的Android推送通知
- 22. Android上的FCM通知是否會覆蓋上一個?
- 23. FCM通知沒有打開預期的活動Android
- 24. 如何使用FCM發送通知XMPP
- 25. 如何使用PHP發送FCM通知?
- 26. 如何顯示從推送通知FCM
- 27. FCM通知標題仍爲「FCM消息」
- 28. FCM:跟蹤狀態FCM推送通知
- 29. 如何發送fcm推送通知使用goalng fcm服務器
- 30. 發送推送IOS上的FCM通知
您可以通過鍵入自定義負載區分在FCM –
打招呼的身體怎麼做到這一點 – Mohamed
檢查我的回答 –