MeSendDataPushPayload.fromRemoteMessage constructor

MeSendDataPushPayload.fromRemoteMessage(
  1. RemoteMessage message
)

Implementation

factory MeSendDataPushPayload.fromRemoteMessage(RemoteMessage message) {
  final data = message.data;
  final notification = message.notification;

  return MeSendDataPushPayload(
    id: _stringOrNull(data['id']),
    type: _stringOrNull(data['type']),
    category: _stringOrNull(data['category']),
    title: _firstNonEmpty([
      notification?.title,
      data['title'],
      data['message1'],
    ]),
    body: _firstNonEmpty([
      notification?.body,
      data['body'],
      data['message'],
      data['message2'],
    ]),
    imageUrl: _firstNonEmpty([
      data['imageUrl'],
      data['image'],
      notification?.android?.imageUrl,
      notification?.apple?.imageUrl,
    ]),
    clickToken: _stringOrNull(data['click_token']),
    rawData: Map<String, dynamic>.from(data),
  );
}