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

本秂侑毒 提交于 2019-12-13 17:33:19

问题


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 hereFLAG_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



来源:https://stackoverflow.com/questions/45962528/open-the-app-automatically-when-you-receive-a-push-notification-with-onesignal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!