-
We are rewriting existing app over to Flutter and use firebase_messaging to handle push messages on Android. Everything is working fine, but we have issue when old app is updated to Flutter app in Play Store: push messages do not work until user manually opens the app. In our app, after initial setup, users only interact with the app when push messages arrive so hoping/waiting for them to manually open the app to fix the push messages is bad user experience. Are there any solutions or suggestions how to best fix this. E.g. a way to register default background handler in Android side without executing Flutter UI? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Came up with following solution: val engine = FlutterEngine(context)
engine.dartExecutor.executeDartEntrypoint(
DartExecutor.DartEntrypoint(
FlutterInjector.instance().flutterLoader().findAppBundlePath(),
"packageReplacedReceiver"
)
) Next registered the method on Flutter side in @pragma("vm:entry-point")
void packageReplacedReceiver() {
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
} So when app is updated, background handler is registered and when first push message arrives app behaves correctly. |
Beta Was this translation helpful? Give feedback.
Came up with following solution:
On Android side, registered
android.intent.action.MY_PACKAGE_REPLACED
BroadcastReceiver, which is called after app is updated. This creates new FlutterEngine:Next registered the method on Flutter side in
main.dart
:So when app is updated, background handler is registered and when first push messag…