Push constructor
Push(
- Map map
Constructor of Push
Implementation
Push(Map map) {
try {
map.forEach((key, value) {
switch (key) {
case _ID:
id = int.parse(value.toString());
break;
case _APP_KEY:
appKey = value.toString();
break;
case _TITLE:
title = value.toString();
break;
case _BODY:
body = value.toString();
break;
case _ICON:
icon = value.toString();
break;
case _IMAGE:
image = value.toString();
break;
case _GIF:
gif = json.decode(value.toString());
break;
case _LAYOUT:
layout = parseLayout(value.toString());
break;
case _DATA:
data = value.toString();
break;
case _SILENT:
silent = value.toString() == "true";
break;
case _SECUREDDATA:
securedData = value.toString();
break;
case _ISDISPOSABLE:
isDisposable = value.toString() == "true";
break;
case _SENDING_ID:
sendingId = value.toString();
break;
case _CAMPAIGN_ID:
campaignId = value.toString();
break;
case _APPLICATION_ID:
applicationId = int.parse(value.toString());
break;
case _PUSH_ID:
pushId = int.parse(value.toString());
break;
case _ACTION:
if (Platform.isAndroid) {
if (value is Map<String, dynamic>) {
action = PushAction(value);
} else if (value is String) {
action = PushAction(json.decode(value));
}
} else {
action = PushAction(value);
}
break;
case _BUTTONS:
List<dynamic>? list;
if (value is List) {
list = value;
}
if (list != null) {
for (var i = 0; i < list.length; i++) {
if (list[i] is String) {
buttons.add(PushButton(json.decode(list[i])));
} else {
var listMap = list[i] as Map;
buttons.add(PushButton(listMap));
}
}
}
break;
case _SEND_EVENT_ACK:
sendEventAck = value.toString() == "true";
break;
case _APPLICATION_ID:
applicationId = int.parse(value.toString());
break;
}
});
} catch (ex) {
print("push object error:" + ex.toString());
}
}