Skip to content

Commit

Permalink
Merge pull request #2129 from OneSignal/fix/xiaomi_foreground_on_click
Browse files Browse the repository at this point in the history
[Fix] Xiaomi notification click not foregrounding app
  • Loading branch information
jkasten2 committed Jun 18, 2024
2 parents f5bf424 + 8f66f8e commit 00e1792
Showing 1 changed file with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,26 @@ import com.onesignal.notifications.internal.open.INotificationOpenedProcessor
abstract class NotificationOpenedActivityBase : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (!OneSignal.initWithContext(applicationContext)) {
return
}

var self = this

suspendifyOnThread {
var openedProcessor = OneSignal.getService<INotificationOpenedProcessor>()
openedProcessor.processFromContext(self, intent)
}

finish()
processIntent()
}

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
processIntent()
}

private fun processIntent() {
if (!OneSignal.initWithContext(applicationContext)) {
return
}

var self = this
suspendifyOnThread {
var openedProcessor = OneSignal.getService<INotificationOpenedProcessor>()
openedProcessor.processFromContext(self, getIntent())
val openedProcessor = OneSignal.getService<INotificationOpenedProcessor>()
openedProcessor.processFromContext(this, intent)
// KEEP: Xiaomi Compatibility:
// Must keep this Activity alive while trampolining, that is
// startActivity() must be called BEFORE finish(), otherwise
// the app is never foregrounded.
finish()
}

finish()
}
}

0 comments on commit 00e1792

Please sign in to comment.