Skip to content

Commit 65a479e

Browse files
committed
Create Silent Notifications
• Adds a constructor to create silent notifications.
1 parent 9f85470 commit 65a479e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/src/create_notification.dart

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,25 @@ class OSCreateNotification extends JSONStringRepresentable {
120120
this.deliveryTimeOfDay
121121
});
122122

123+
OSCreateNotification.silentNotification({
124+
@required this.playerIds,
125+
this.additionalData,
126+
this.sendAfter,
127+
this.delayedOption,
128+
this.deliveryTimeOfDay
129+
}) {
130+
this.contentAvailable = true;
131+
}
132+
123133
Map<String, dynamic> mapRepresentation() {
124134
if (this.languageCode == null) this.languageCode = "en";
125135

126-
var json = {
127-
"include_player_ids" : this.playerIds,
128-
"contents" : {
129-
this.languageCode : this.content
130-
}
136+
var json = <String, dynamic> {
137+
"include_player_ids" : this.playerIds
131138
};
132139

133140
// add optional parameters to payload if present
141+
if (this.content != null) json['contents'] = { this.languageCode : this.content };
134142
if (this.heading != null) json['headings'] = { this.languageCode : this.heading };
135143
if (this.subtitle != null) json['subtitle'] = { this.languageCode : this.heading };
136144
if (this.contentAvailable != null) json['content_available'] = this.contentAvailable;

0 commit comments

Comments
 (0)