Tapping a Notification from OneSignal does not open a result activity!!!! - Android

本小妞迷上赌 提交于 2019-12-03 16:56:17
Think Twice Code Once

Take a look at this link: https://documentation.onesignal.com/docs/android-customizations#section-background-data-and-notification-overriding (Search : "Changing the open action of a notification" in the page to go to the exact paragraph).

And this is an example: http://androidbash.com/android-push-notification-service-using-onesignal/

I don't have time to read your code carefully, but seems like it has some problems:

  1. You initialize OneSignal in the wrong place.

    "Make sure you are initializing OneSignal with setNotificationOpenedHandler in the onCreate method in your Application class. You will need to call startActivity from this callback" (OneSignal's document).

  2. You don't need any other receivers in AndroidManifest to catch intent and open your target activity, OneSignal.NotificationOpenedHandler already handle this. But don't forget this line to prevent OneSignal open your launcher activity:

<application ...>
   <meta-data android:name="com.onesignal.NotificationOpened.DEFAULT"  android:value="DISABLE" />
</application>

I use this solution in my app and it works fine. Because it's the way it is.

OneSignal.init must be called from your launcher Activity, you will need to move it to your splashscreen Activity. This will get your ExampleNotificationOpenedHandler to fire when you open a OneSignal notification.

Make sure to also copy the calls to OneSignal.onPaused(); and OneSignal.onResumed(); into your splashscreen Activity. These need to be called in every Activity in the onPuase() and onResume() methods.

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