meSendHandleBackgroundRemoteMessage function
Future<void>
meSendHandleBackgroundRemoteMessage(
- RemoteMessage message, {
- required FirebaseOptions options,
Handles an FCM message in a background isolate.
Call from a host @pragma('vm:entry-point') top-level function so
FirebaseOptions are resolved inside the background isolate:
@pragma('vm:entry-point')
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await meSendHandleBackgroundRemoteMessage(
message,
options: DefaultFirebaseOptions.currentPlatform,
);
}
In main:
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
Implementation
Future<void> meSendHandleBackgroundRemoteMessage(
RemoteMessage message, {
required FirebaseOptions options,
}) async {
final ready =
await MeSendPushNotificationDisplay.ensureFirebaseInitializedForBackground(
options: options,
);
if (!ready) {
return;
}
meherySenderLog('SDK background handler invoked', tag: 'Push|background');
MeSendPushNotificationDisplay.logPayload(message, 'background');
await MeSendPushNotificationDisplay.handleRemoteMessage(
message,
source: 'background',
);
}