handleRemoteMessage static method
Handles RemoteMessage in foreground, background, or terminated flows.
Implementation
static Future<void> handleRemoteMessage(
RemoteMessage message, {
required String source,
}) async {
final payload = MeSendDataPushPayload.fromRemoteMessage(message);
meherySenderLog(
'data-only parsed → type=${payload.type}, category=${payload.category}, '
'title=${payload.title}, body=${payload.body}, '
'showTray=${payload.shouldShowTrayNotification}',
tag: 'Push|$source',
);
if (!payload.shouldShowTrayNotification) {
meherySenderLog(
'skip tray (in-app type or empty): ${payload.type}',
tag: 'Push|$source',
);
return;
}
// Android already displays notification-block payloads when backgrounded.
if (Platform.isAndroid &&
source == 'background' &&
message.notification != null) {
meherySenderLog(
'notification block present — system may display; skipping local tray',
tag: 'Push|background',
);
return;
}
// iOS with a notification block is shown by the system in foreground.
if (Platform.isIOS &&
source == 'foreground' &&
message.notification != null) {
return;
}
await _showTrayNotification(message, payload, source);
}