parseRemoteMessage method
Implementation
NotificationMessage parseRemoteMessage(RemoteMessage remote) {
final raw = _jsonMap(remote.toMap());
final data = _jsonMap(remote.data);
return parseMap(<String, Object?>{
...data,
if (remote.notification?.title != null)
'title': remote.notification!.title,
if (remote.notification?.body != null) 'body': remote.notification!.body,
if (remote.notification?.android?.imageUrl != null)
'image_url': remote.notification!.android!.imageUrl,
if (remote.notification?.apple?.imageUrl != null)
'image_url': remote.notification!.apple!.imageUrl,
if (remote.category != null) 'category_id': remote.category,
if (remote.messageId != null) 'message_id': remote.messageId,
if (remote.sentTime != null)
'sent_at': remote.sentTime!.toIso8601String(),
if (remote.collapseKey != null) 'collapse_key': remote.collapseKey,
if (remote.from?.startsWith('/topics/') ?? false)
'topic': remote.from!.substring('/topics/'.length),
if (remote.contentAvailable) 'silent': true,
}, rawJson: raw);
}