File tree Expand file tree Collapse file tree 1 file changed +12
-18
lines changed
OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/activities Expand file tree Collapse file tree 1 file changed +12
-18
lines changed Original file line number Diff line number Diff line change @@ -36,32 +36,26 @@ import com.onesignal.notifications.internal.open.INotificationOpenedProcessor
3636abstract class NotificationOpenedActivityBase : Activity () {
3737 override fun onCreate (savedInstanceState : Bundle ? ) {
3838 super .onCreate(savedInstanceState)
39- if (! OneSignal .initWithContext(applicationContext)) {
40- return
41- }
42-
43- var self = this
44-
45- suspendifyOnThread {
46- var openedProcessor = OneSignal .getService<INotificationOpenedProcessor >()
47- openedProcessor.processFromContext(self, intent)
48- }
49-
50- finish()
39+ processIntent()
5140 }
5241
5342 override fun onNewIntent (intent : Intent ) {
5443 super .onNewIntent(intent)
44+ processIntent()
45+ }
46+
47+ private fun processIntent () {
5548 if (! OneSignal .initWithContext(applicationContext)) {
5649 return
5750 }
58-
59- var self = this
6051 suspendifyOnThread {
61- var openedProcessor = OneSignal .getService<INotificationOpenedProcessor >()
62- openedProcessor.processFromContext(self, getIntent())
52+ val openedProcessor = OneSignal .getService<INotificationOpenedProcessor >()
53+ openedProcessor.processFromContext(this , intent)
54+ // KEEP: Xiaomi Compatibility:
55+ // Must keep this Activity alive while trampolining, that is
56+ // startActivity() must be called BEFORE finish(), otherwise
57+ // the app is never foregrounded.
58+ finish()
6359 }
64-
65- finish()
6660 }
6761}
You can’t perform that action at this time.
0 commit comments