Skip to content

Commit 8cd6679

Browse files
committed
Fixed parsing for 'notification_ids' after changes to iOS SDK
* Handle the case for if the 'notification_ids' in OSOutcomeEvent is a List as a string or as a List * Removed not needed @implementation inside of 'OSFlutterCategories'
1 parent 1d19d8f commit 8cd6679

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

ios/Classes/OSFlutterCategories.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@
4747
- (NSDictionary *)toJson;
4848
@end
4949

50-
// TODO: Will reference the OSOutcomeEvent in OneSignal.h
51-
//@interface OSOutcomeEvent (Flutter)
52-
//- (NSDictionary *)toJson;
53-
//@end
54-
5550
@interface NSError (Flutter)
5651
- (FlutterError *)flutterError;
5752
@end

ios/Classes/OSFlutterCategories.m

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,6 @@ - (NSDictionary *)toJson {
112112
}
113113
@end
114114

115-
// TODO: Will reference the OSOutcomeEvent in OneSignal.h
116-
//@implementation OSOutcomeEvent (Flutter)
117-
//- (NSDictionary *)toJson {
118-
// NSMutableDictionary *json = [NSMutableDictionary new];
119-
//
120-
// json[@"session"] = self.session;
121-
// json[@"notification_ids"] = self.notificationIds;
122-
// json[@"name"] = self.name;
123-
// json[@"timestamp"] = self.timestamp;
124-
// json[@"weight"] = self.weight;
125-
//
126-
// return json;
127-
//}
128-
//@end
129-
130115
@implementation NSError (Flutter)
131116
- (FlutterError *)flutterError {
132117
return [FlutterError errorWithCode:[NSString stringWithFormat:@"%i", (int)self.code] message:self.localizedDescription details:nil];

lib/src/outcome_event.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,16 @@ class OSOutcomeEvent extends JSONStringRepresentable {
4646
OSSession.DISABLED;
4747

4848
// Make sure notification_ids exists
49-
this.notificationIds = outcome.containsKey("notification_ids") && outcome["notification_ids"] != null ?
50-
new List<String>.from(json.decode(outcome["notification_ids"])) :
51-
[];
49+
if (outcome.containsKey("notification_ids") && outcome["notification_ids"] != null) {
50+
if (outcome["notification_ids"] is List) {
51+
// Handle if type comes in as a List
52+
this.notificationIds = (outcome["notification_ids"] as List).map<String>((s) => s).toList();
53+
}
54+
else if (outcome["notification_ids"] is String) {
55+
// Handle if type comes in as a String
56+
this.notificationIds = new List<String>.from(json.decode(outcome["notification_ids"]));
57+
}
58+
}
5259

5360
// Make sure name exists
5461
this.name = outcome.containsKey("id") && outcome["id"] != null ?

0 commit comments

Comments
 (0)