talkjs / talkjs-flutter

Flutter SDK for the TalkJS Chat API
https://talkjs.com
BSD 3-Clause "New" or "Revised" License
9 stars 14 forks source link

[Android] No push notifications while app is killed #42

Closed lotekbard closed 7 months ago

lotekbard commented 1 year ago

Hello!

I have problem with push notifications on Android while app is killed. I do have Firebase push notifications in my app which are working fine. While sending push from Firebase console I am receiving it no matter if the app is in foreground, background or killed. Push notification from talkJs are showing only while the app is in foreground or background. No chat notifications are received while app is killed. This behavior appy only to Android (iOS is seems to be working).

Looking for help or confirmation that pushes from talkJs chat are working on Android while the app is terminated. Thank you!

vickz84259 commented 7 months ago

Hey, sorry for the late response. During my initial investigations, I missed a key log message in the logcat messages that could have helped explained why the background handler wasn't being called despite following the guidelines listed here: https://firebase.google.com/docs/cloud-messaging/flutter/receive#apple_platforms_and_android.

The log message in question was: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.talkjs.flutter_push_example (has extras) }. This only occurs when running a debug application either via Android Studio or Flutter command line.

With that out of the way, our background handler is being called however it currently expects there to exist a main isolate which doesn't exist when the app has been terminated. Only the background isolate where the message handler is running exists when a message arrives after the app has been terminated.

I am going to look into refactoring our background handler to address this issue. Thank you for your patience.