jsonDictionaryForPushMessage static method

Map<String, dynamic> jsonDictionaryForPushMessage(
  1. MBPushMessage pushMessage
)

Converts a push to a JSON dictionary. @param pushMessage The push message to convert. @returns The Map that represent the push message.

Implementation

static Map<String, dynamic> jsonDictionaryForPushMessage(
    MBPushMessage pushMessage) {
  Map<String, dynamic> dictionary = {
    'id': pushMessage.id,
    'title': pushMessage.title,
    'body': pushMessage.body,
    'sent': pushMessage.sent,
  };

  if (pushMessage.badge != null) {
    dictionary['badge'] = pushMessage.badge;
  }
  if (pushMessage.sound != null) {
    dictionary['sound'] = pushMessage.sound;
  }
  if (pushMessage.launchImage != null) {
    dictionary['launchImage'] = pushMessage.launchImage;
  }
  if (pushMessage.userInfo != null) {
    dictionary['userInfo'] = pushMessage.userInfo;
  }
  return dictionary;
}