mirzemehdi / KMPNotifier

Kotlin Multiplatform Push Notification Library targetting android, iOS, Desktop and Web (JS and Wasm)
http://mirzemehdi.com/KMPNotifier/
Apache License 2.0
312 stars 17 forks source link

Android Not trigerring listener when clicking post notification while the app is cleaned from recent apps #74

Open Deorigami opened 3 weeks ago

Deorigami commented 3 weeks ago

My issue is different from this https://github.com/mirzemehdi/KMPNotifier/issues/73

If my app is cleaned from recent app or killed, then i pushed an FCM, the notification is arrive but when i clicked it, the listener doesnt trigger anything tho the intent.extras is containing all the data/payload

mirzemehdi commented 2 weeks ago

@Deorigami My guess is that, it is triggered, but because you killed the app, you don't see the logs in Android Studio until you open it.

Also, where do you set listeners?

mirzemehdi commented 2 weeks ago

Please make sure this is added into your launcher activity. Also you set listener on app initialization, at least before this launcher activity is created


override fun onCreate(savedInstanceState: Bundle?) {
   super.onCreate(savedInstanceState)
      NotifierManager.onCreateOrOnNewIntent(intent)
      ...
    }

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        NotifierManager.onCreateOrOnNewIntent(intent)
    }
Deorigami commented 2 weeks ago

@Deorigami My guess is that, it is triggered, but because you killed the app, you don't see the logs in Android Studio until you open it.

Also, where do you set listeners?

of course it is because i kill the app, i initialized it in onCreate Application, if i check in onCreate intent.extras, the extras is there

mirzemehdi commented 2 weeks ago

@Deorigami which listener is not triggered exactly?

there is this condition to trigger in the codebase

https://github.com/mirzemehdi/KMPNotifier/blob/fe729de97830240ef2a1799959c15e13de53c25d/kmpnotifier/src/androidMain/kotlin/com/mmk/kmpnotifier/extensions/NotifierManagerExt.kt#L42