![](/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.