![](/img/trans.png)
[英]Retrieve notification values from a notification in system tray android firebase FCM
[英]Handle dismissed Firebase notification in Android System Tray
在onMessageReceived方法中,我將一些數據保存在本地數據庫中。
如果我點擊通知時應用程序處於后台 ,則會將我重定向到啟動器活動。 我正在處理來自Bundle的傳入數據並將其保存在本地數據庫中。
當用戶解除通知時,我該如何處理? 因為如果用戶解除通知,我從服務器收到的數據將丟失。
您可以使用BroadCast Reciever在收到數據時保存這些鏈接: https : //developer.android.com/guide/components/broadcasts.html
您可以通過向通知構建器添加deleteIntent來處理解雇。 使用intent,將收到的數據添加到其中並將其重定向到處理程序類。 在處理程序類中提取數據並保存到db :)
mBuilder.setDeleteIntent(PendingIntent.getService(this, 0, new Intent(this.context, YourHandlingClass.class), PendingIntent.FLAG_CANCEL_CURRENT));
刪除通知時已修復,並使用了fcm的DATA方法。
謝謝@DivyeshPatel
1.您可以直接將數據保存到onMessageReceived中的本地數據庫,而不是等待用戶打開通知。
2.禁用自動取消
notication.setAutoCancel(false)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.