@@ -8,90 +8,90 @@ import 'package:OneSignalFlutter/onesignal.dart';
88/// a Create Notification object as an entirely different class
99class OSCreateNotification extends JSONStringRepresentable {
1010
11- /// An array of user ID's that should receive this notification
12- List <String > playerIds;
11+ /// An array of user ID's that should receive this notification
12+ List <String > playerIds;
1313
14- /// The notification's content (excluding title)
15- String content;
14+ /// The notification's content (excluding title)
15+ String content;
1616
17- /// The language code (ie. "en" for English) for this notification
18- /// defaults to "en" (English)
19- String languageCode;
17+ /// The language code (ie. "en" for English) for this notification
18+ /// defaults to "en" (English)
19+ String languageCode;
2020
21- /// The title/heading for the notification
22- String heading;
21+ /// The title/heading for the notification
22+ String heading;
2323
24- /// The subtitle for the notification (iOS 10+ only)
25- String subtitle;
24+ /// The subtitle for the notification (iOS 10+ only)
25+ String subtitle;
2626
27- /// Tells the app to launch in the background (iOS only)
28- bool contentAvailable;
27+ /// Tells the app to launch in the background (iOS only)
28+ bool contentAvailable;
2929
30- /// Tells the app to launch the Notification Service extension,
31- /// which can mutate your notification (ie. download attachments)
32- bool mutableContent;
30+ /// Tells the app to launch the Notification Service extension,
31+ /// which can mutate your notification (ie. download attachments)
32+ bool mutableContent;
3333
34- /// Additional data you wish to send with the notification
35- Map <String , dynamic > additionalData;
34+ /// Additional data you wish to send with the notification
35+ Map <String , dynamic > additionalData;
3636
37- /// The URL to open when the user taps the notification
38- String url;
37+ /// The URL to open when the user taps the notification
38+ String url;
3939
40- /// Media (images, videos, etc.) for iOS
41- /// Maps a custom ID to a resource URL
42- /// in the format {'id' : 'https://.....'}
43- Map <String , String > iosAttachments;
40+ /// Media (images, videos, etc.) for iOS
41+ /// Maps a custom ID to a resource URL
42+ /// in the format {'id' : 'https://.....'}
43+ Map <String , String > iosAttachments;
4444
45- /// An image to use as the big picture (android only)
46- String bigPicture;
45+ /// An image to use as the big picture (android only)
46+ String bigPicture;
4747
48- /// A list of buttons to attach to the notification
49- List <OSActionButton > buttons;
48+ /// A list of buttons to attach to the notification
49+ List <OSActionButton > buttons;
5050
51- /// The category identifier for iOS (controls various aspects
52- /// of the notification, for example, whether to launch a
53- /// Notification Content Extension) (iOS only)
54- String iosCategory;
51+ /// The category identifier for iOS (controls various aspects
52+ /// of the notification, for example, whether to launch a
53+ /// Notification Content Extension) (iOS only)
54+ String iosCategory;
5555
56- /// The sound to play (iOS only)
57- String iosSound;
56+ /// The sound to play (iOS only)
57+ String iosSound;
5858
59- /// The sound to play (Android only)
60- String androidSound;
59+ /// The sound to play (Android only)
60+ String androidSound;
6161
62- /// A small icon (Android only)
63- /// Can be a drawable resource name or a URL
64- String androidSmallIcon;
62+ /// A small icon (Android only)
63+ /// Can be a drawable resource name or a URL
64+ String androidSmallIcon;
6565
66- /// A large icon (android only)
67- /// Can be a drawable resource name or a URL
68- String androidLargeIcon;
66+ /// A large icon (android only)
67+ /// Can be a drawable resource name or a URL
68+ String androidLargeIcon;
6969
70- /// The Android Oreo Notification Category to send the notification under
71- String androidChannelId;
70+ /// The Android Oreo Notification Category to send the notification under
71+ String androidChannelId;
7272
73- /// can be 'Increase' or 'SetTo'
74- OSCreateNotificationBadgeType iosBadgeType;
73+ /// can be 'Increase' or 'SetTo'
74+ OSCreateNotificationBadgeType iosBadgeType;
7575
76- /// The actual badge count to either set to directly, or increment by
77- /// To decrement the user's badge count, send a negative value
78- int iosBadgeCount;
76+ /// The actual badge count to either set to directly, or increment by
77+ /// To decrement the user's badge count, send a negative value
78+ int iosBadgeCount;
7979
80- /// If multiple notifications have the same collapse ID, only the most
81- /// recent notification will be shown
82- String collapseId;
80+ /// If multiple notifications have the same collapse ID, only the most
81+ /// recent notification will be shown
82+ String collapseId;
8383
84- /// Allows you to send a notification at a specific date
85- DateTime sendAfter;
84+ /// Allows you to send a notification at a specific date
85+ DateTime sendAfter;
8686
87- /// You can use several options to send notifications at specific times
88- /// ie. you can send notifications to different user's at the same time
89- /// in each timezone with the 'timezone' delayedOption
90- OSCreateNotificationDelayOption delayedOption;
87+ /// You can use several options to send notifications at specific times
88+ /// ie. you can send notifications to different user's at the same time
89+ /// in each timezone with the 'timezone' delayedOption
90+ OSCreateNotificationDelayOption delayedOption;
9191
92- /// Used with delayedOption == timezone, lets you specify what time of day
93- /// each user should receive the notification, ie. "9:00 AM"
94- String deliveryTimeOfDay;
92+ /// Used with delayedOption == timezone, lets you specify what time of day
93+ /// each user should receive the notification, ie. "9:00 AM"
94+ String deliveryTimeOfDay;
9595
9696 OSCreateNotification ({
9797 @required this .playerIds,
@@ -140,7 +140,7 @@ class OSCreateNotification extends JSONStringRepresentable {
140140 // add optional parameters to payload if present
141141 if (this .content != null ) json['contents' ] = { this .languageCode : this .content };
142142 if (this .heading != null ) json['headings' ] = { this .languageCode : this .heading };
143- if (this .subtitle != null ) json['subtitle' ] = { this .languageCode : this .heading };
143+ if (this .subtitle != null ) json['subtitle' ] = { this .languageCode : this .subtitle };
144144 if (this .contentAvailable != null ) json['content_available' ] = this .contentAvailable;
145145 if (this .mutableContent != null ) json['mutable_content' ] = this .mutableContent;
146146 if (this .additionalData != null ) json['data' ] = this .additionalData;
@@ -164,9 +164,9 @@ class OSCreateNotification extends JSONStringRepresentable {
164164
165165 // adds buttons
166166 if (this .buttons != null ) {
167- json[ 'buttons' ] = this .buttons. map ((btn) {
168- return btn.mapRepresentation ();
169- }) ;
167+ var btns = List < Map < String , dynamic >>();
168+ this .buttons. forEach ((btn) => btns. add ( btn.mapRepresentation ()) );
169+ json[ 'buttons' ] = btns ;
170170 }
171171
172172 return json;
0 commit comments