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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
you can try with this,hope this code will help you.
Intent restart = context.getPackageManager().
getLaunchIntentForPackage(context.getPackageName());
restart.addFlags(Intent.enter code here
FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(restart);
回答2:
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