pushy / pushy-flutter

The official Pushy SDK for Flutter apps.
Apache License 2.0
21 stars 19 forks source link

Notifications not showing when app is killed (Android) #33

Closed ricardonior29 closed 3 years ago

ricardonior29 commented 3 years ago

Device pixel 3a

2021-07-23 16:24:41.737 30589-30589/com.example.app E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.app, PID: 30589 java.lang.NullPointerException: Attempt to read from field 'java.lang.String io.flutter.embedding.engine.loader.FlutterApplicationInfo.flutterAssetsDir' on a null object reference at io.flutter.embedding.engine.loader.FlutterLoader.findAppBundlePath(FlutterLoader.java:364) at io.flutter.view.FlutterMain.findAppBundlePath(FlutterMain.java:104) at me.pushy.sdk.flutter.util.PushyFlutterBackgroundExecutor.startBackgroundIsolate(PushyFlutterBackgroundExecutor.java:76) at me.pushy.sdk.flutter.util.PushyFlutterBackgroundExecutor.startBackgroundIsolate(PushyFlutterBackgroundExecutor.java:55) at me.pushy.sdk.flutter.PushyPlugin$3.run(PushyPlugin.java:314) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

pushy commented 3 years ago

Hi @ricardonior29 , We'd be glad to assist.

Please ensure your Flutter Android project has been updated to Flutter 1.12+ for compatibility with the new version of our plugin:

1) Your android/app/src/main/AndroidManifest.xml should contain a <meta-data> attribute labeled flutterEmbedding with a value of 2 inside the <application> tag:

<meta-data
    android:name="flutterEmbedding"
    android:value="2" />

2) Due to a Flutter platform bug, and contrary to the Flutter 1.12 upgrade docs, please ensure that your <application> tag does contain an android:name="" attribute with a value set to io.flutter.app.FlutterApplication, for notifications to be received while the app is not running:

<application
  android:name="io.flutter.app.FlutterApplication"
  >
  <!-- code omitted -->
</application>

Please let us know if it resolves the issue.

ricardonior29 commented 3 years ago

Thank you very much, it worked. I was missing to add android:name="io.flutter.app.FlutterApplication". But I'm still wondering if that was in the documentation.

pushy commented 3 years ago

HI @ricardonior29, It has been added to the Flutter docs about 5 days ago. If you implemented before then, then it was not in the docs.

Glad to hear it works now!