Skip to content

Commit 03c8bbe

Browse files
gnpricechrisbobbe
authored andcommitted
notif: Add vm:entry-point pragma to _onBackgroundMessage
This fixes part of #528, following the suggestion n-92 made here: #342 (comment) Even with this change, notifications still don't yet work on Android in release builds. But after this change, when the app wasn't in the foreground, they get farther than before. Specifically they get just as far as they get, with or without this change, when the app was in the foreground. Details here: #528 (comment)
1 parent abc65a2 commit 03c8bbe

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/notifications.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ class NotificationService {
174174
_onRemoteMessage(message);
175175
}
176176

177+
// This pragma `vm:entry-point` is needed in release mode, when this method
178+
// is needed at all (i.e. on Android):
179+
// https://firebase.google.com/docs/cloud-messaging/flutter/receive#background_messages
180+
// https://github.com/firebase/flutterfire/issues/9446#issuecomment-1240554285
181+
// https://github.com/zulip/zulip-flutter/issues/528#issuecomment-1960646800
182+
@pragma('vm:entry-point')
177183
static Future<void> _onBackgroundMessage(FirebaseRemoteMessage message) async {
178184
// This callback will run in a separate isolate from the rest of the app.
179185
// See docs:

0 commit comments

Comments
 (0)