[英]how to know if app is in background or foreground when push notification is received using IBM Mobilefirst
I have a Android Native App which is integrated with IBM MobileFirst SDK. 我有一个与IBM MobileFirst SDK集成的Android Native App。
My requirement is I receive a Push Notification when app is in foreground I need to show a dialog in the UI. 我的要求是,当应用程序处于前台时,我会收到一个推送通知,我需要在UI中显示一个对话框。 But when App is in Background and receives a Push notification in the notification drawer of the phone and I click on it It should open the app but should not show any Dialog.
但是,当应用程序在后台并且在电话的通知抽屉中收到推式通知时,我单击它,它将打开应用程序,但不显示任何对话框。
How do I differentiate these two cases because the call back that is happening on these both cases is onMessage(String props, final String payload) ? 我如何区分这两种情况,因为在这两种情况下发生的回调都是onMessage(String props,final String payload)吗?
So I am unable tell wether the notification reached notification drawer or directly to the app. 因此,我无法确定通知是否到达通知抽屉或直接发送到应用程序。
I am using MobileFirst 7.1 我正在使用MobileFirst 7.1
You need to track your app visibility state by yourself. 您需要自己跟踪应用的可见性状态。 Easiest way to do this is to implement Application.ActivityLifecycleCallbacks and detect your Activity state.
最简单的方法是实现Application.ActivityLifecycleCallbacks并检测您的Activity状态。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.