RDNotificationResponseModel.fromJson constructor
RDNotificationResponseModel.fromJson(
- Map<String, dynamic> json
)
Implementation
RDNotificationResponseModel.fromJson(Map<String, dynamic> json) {
payload = json;
if (payload != null) {
if (Platform.isIOS) {
dynamic userInfo = payload['userInfo'];
if (userInfo != null) {
if (userInfo.containsKey('pushType') &&
userInfo['pushType'] != null &&
userInfo['pushType'].runtimeType == String) {
String tempPushType = userInfo['pushType'] as String;
if (tempPushType.isNotEmpty) {
pushType = tempPushType;
}
}
if (userInfo.containsKey('pushId') &&
userInfo['pushId'] != null &&
userInfo['pushId'].runtimeType == String) {
pushId = userInfo['pushId'] as String;
}
if (userInfo.containsKey('url') &&
userInfo['url'] != null &&
userInfo['url'].runtimeType == String) {
url = userInfo['url'] as String;
deepLink = userInfo['url'] as String;
}
if (userInfo.containsKey('deepLink') &&
userInfo['deepLink'] != null &&
userInfo['deepLink'].runtimeType == String) {
url = userInfo['deepLink'] as String;
deepLink = userInfo['deepLink'] as String;
}
if (userInfo.containsKey('altUrl') &&
userInfo['altUrl'] != null &&
userInfo['altUrl'].runtimeType == String) {
altUrl = userInfo['altUrl'] as String;
}
if (userInfo.containsKey('mediaUrl') &&
userInfo['mediaUrl'] != null &&
userInfo['mediaUrl'].runtimeType == String) {
altUrl = userInfo['mediaUrl'] as String;
}
if (userInfo.containsKey('aps') &&
userInfo['aps'] != null &&
userInfo['mediaUrl'].runtimeType == Map<String, dynamic>) {
Map<String, dynamic> aps = userInfo["aps"] as Map<String, dynamic>;
if (aps.containsKey('content-available') &&
aps['content-available'] != null &&
aps['content-available'].runtimeType == int) {
contentAvailable = aps['content-available'] as int;
}
if (aps.containsKey('mutable-content') &&
aps['mutable-content'] != null &&
aps['mutable-content'].runtimeType == int) {
mutableContent = aps['mutable-content'] as int;
}
if (aps.containsKey('badge') &&
aps['badge'] != null &&
aps['badge'].runtimeType == int) {
badge = aps['badge'] as int;
}
if (aps.containsKey('sound') &&
aps['sound'] != null &&
aps['sound'].runtimeType == String) {
sound = aps['sound'] as String;
}
if (aps.containsKey('alert') &&
aps['alert'] != null &&
aps.runtimeType == Map<String, dynamic>) {
Map<String, dynamic> alert = aps["alert"] as Map<String, dynamic>;
if (alert.containsKey('title') &&
alert['title'] != null &&
alert['title'].runtimeType == String) {
title = alert['title'] as String;
}
if (alert.containsKey('body') &&
alert['body'] != null &&
alert['body'].runtimeType == String) {
body = alert['body'] as String;
}
}
}
}
}
}
}