[英]How to Enable Push notification when user closes App and disable when user open app
There is a problem that I am using OneSignal for push notification in my app, I want onesignal's NotificationExtenderService
should start when user closes the app and stop when user opens app 我在应用程序中使用OneSignal进行推送通知时遇到问题,我希望onesignal的NotificationExtenderService
应该在用户关闭应用程序时启动,并在用户打开应用程序时停止
in other words,disable service when app is launched and enable when app is closed, 换句话说,在启动应用程序时禁用服务,在关闭应用程序时启用服务,
Please Help! 请帮忙!
Since you tagged with Firebase, I assume that Firebase Cloud Messaging (FCM) is involved. 由于您已用Firebase标记,因此我假定涉及Firebase Cloud Messaging(FCM)。 FCM has two message types: FCM有两种消息类型:
Notification messages are handed by the system when you app isn't active, and delivered to your code when the app is active. 通知消息是由系统交给你时,应用程序是不活跃的,当应用程序被激活发送到您的代码。 This means that in its default behavior (ie if you only add the SDK and no custom code to the app) shuld be precisely what you describe: 这意味着,按照其默认行为(即,如果您仅添加SDK且没有向应用程序添加自定义代码)应该正是您所描述的内容:
Data messages are always deliver to the code in your app. 数据消息始终传递到应用程序中的代码。 This means that you code can determine whether to display a notification or not. 这意味着您的代码可以确定是否显示通知。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.