Skip to content

Commit cb0e6ba

Browse files
authored
nil check on notificationIds before converting it into a string (#573)
* nil check on notificationIds before converting it into a string * Release 2.12.2 * Prevent side effects by not assigning object directly * Updated binary
1 parent 3828d5a commit cb0e6ba

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

OneSignal.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "OneSignal"
3-
s.version = "2.12.1"
3+
s.version = "2.12.2"
44
s.summary = "OneSignal push notification library for mobile apps."
55
s.homepage = "https://onesignal.com"
66
s.license = { :type => 'MIT', :file => 'LICENSE' }
Binary file not shown.

iOS_SDK/OneSignalSDK/Source/OSOutcomeEvent.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,20 @@ - (NSDictionary * _Nonnull)jsonRepresentation {
5151
let json = [NSMutableDictionary new];
5252

5353
json[@"session"] = OS_SESSION_TO_STRING(self.session);
54+
json[@"id"] = self.name;
55+
json[@"timestamp"] = @(self.timestamp.intValue);
56+
json[@"weight"] = self.weight.stringValue;
57+
58+
if (!self.notificationIds) {
59+
json[@"notification_ids"] = [NSArray new];
60+
return json;
61+
}
5462

5563
NSError *error;
5664
NSData *jsonNotificationIds = [NSJSONSerialization dataWithJSONObject:self.notificationIds options:NSJSONWritingPrettyPrinted error:&error];
5765
NSString *stringNotificationIds = [[NSString alloc] initWithData:jsonNotificationIds encoding:NSUTF8StringEncoding];
5866
json[@"notification_ids"] = stringNotificationIds;
5967

60-
json[@"id"] = self.name;
61-
json[@"timestamp"] = @(self.timestamp.intValue);
62-
json[@"weight"] = self.weight.stringValue;
63-
6468
return json;
6569
}
6670

iOS_SDK/OneSignalSDK/Source/OneSignal.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ @interface OneSignal (SessionStatusDelegate)
132132

133133
@implementation OneSignal
134134

135-
NSString* const ONESIGNAL_VERSION = @"021201";
135+
NSString* const ONESIGNAL_VERSION = @"021202";
136136
static NSString* mSDKType = @"native";
137137
static BOOL coldStartFromTapOnNotification = NO;
138138

0 commit comments

Comments
 (0)