pushy/pushy-flutter

Notification does not work when app is closed on Android emulator and device.

Closed this issue ยท 7 comments

How are you?
I am using pushy_flutter: ^1.1.8.
While the app is closed, Notification does not come to both Android emulator and device.
I tested pushy-flutter-demo. but it is not working for me.
When app is in background, notification is working well.
Is there a way to fix this issue?

pushy commented

I don't think it is because of a device.

Your demo is working well for me
But If app has many packages, Notification does not work without any error in the background.

Hi,
I found the issue.
My app is using flutter_rtmp_publisher: ^0.0.1.
If I removed the package, the notification works well even if the app is closed.
But I need the RTMP package, can you fix the issue?
Thank you.

pushy commented

Hi @liqiang1995,
Yes, it is most likely that the flutter_rtmp_publisher is throwing an exception because it is trying to access activity() when the isolate is being started.

Please check if there is any exception thrown, when receiving a notification while your app is closed and the plugin installed?

Run adb logcat and post the exception here.

pushy commented

Hi @liqiang1995,
Indeed, the plugin flutter_rtmp_publisher was designed for foreground use only and is trying to access registrar.activity() in registerWith() which is null when a Flutter background isolate is started.
https://github.com/ponnamkarthik/FlutterRtmpPlublisher/blob/8ae222dc6850fb2f01ad4716d59774c19ac37dc5/android/src/main/kotlin/io/github/ponnamkarthik/flutterrtmppublisher/FlutterRtmpPublisherPlugin.kt#L51

      channel.setMethodCallHandler(FlutterRtmpPublisherPlugin(registrar.activity()))

Please edit the outdated plugin to check for a null registrar.activity(), as mentioned here:
https://stackoverflow.com/a/58813854

thank you.
Let me try so.