[英]Android - Handle local notification when app in foreground
My app receives FCM and fires local notifications, which open target activities. 我的应用程序收到FCM并触发本地通知,从而打开目标活动。 This works fine if the local notification is clicked when the app is not running.
如果在未运行应用程序时单击本地通知,则此方法效果很好。
But, if the local notification is clicked when my app is already running (foreground or background), I don't want to open the target activity but shows an AlertDialog first. 但是,如果在我的应用程序已经运行(前台或后台)时单击了本地通知,则我不想打开目标活动,而是先显示AlertDialog。 So, the activities stack is not changed and the user can continue what he was doing before.
因此,活动堆栈不会更改,并且用户可以继续之前的操作。
It seems the local notification must have an action, which opens activities. 看来本地通知必须有一个操作才能打开活动。 Is there anyway achieve what I wanted above?
无论如何,有什么可以实现我上面想要的?
I think you have to stop sending push notification when you app is in foreground check if your app is in foreground or by following this link 我认为您必须在应用程序处于前台状态时停止发送推送通知,请检查您的应用程序是否处于前台状态或通过以下链接
check android application is in foreground or not? 检查android应用程序是否在前台?
check this in firebaseMessegingService class before sending PN and manage alert dialog appearance according that 发送PN之前,请在firebaseMessegingService类中进行检查,并根据提示管理警报对话框的外观
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.