Open the app automatically when you receive a push notification with onesignal

1k Views Asked by At

I would like to be able to open an activity in the application when a push notification is received without any user action. Is it possible to do with onesignal or some other way to open the app automatically using a push?

2

There are 2 best solutions below

2
On

You can simply start your home activity inside FirebaseMessagingService.onMessageReceived But if application is currently running you don't have to do that. You need kind of controller and check is application in foreground

0
On

you can try with this,hope this code will help you.

Intent restart = context.getPackageManager(). getLaunchIntentForPackage(context.getPackageName()); restart.addFlags(Intent.enter code hereFLAG_ACTIVITY_CLEAR_TOP); context.startActivity(restart);