简体   繁体   中英

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

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. FCM has two message types:

  • Notification messages
  • Data messages

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:

  • If the app is not active, incoming notifications are displayed in the system tray.
  • If the app is active, incoming notifications are not displayed.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM