Skip to content

Commit 2d36506

Browse files
Nightsd01jkasten2
authored andcommitted
Fixes an iOS 9 crash with push notifications containing buttons
* With the new payload format, if a user selected an action on a push notification in iOS 9 the app would crash. This is because the payload format is different in iOS 9. Added a check for this condition to parse it appropriately
1 parent bef5ad7 commit 2d36506

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

iOS_SDK/OneSignalSDK/Source/OSNotificationPayload.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,14 @@ -(void)parseOSDataPayload {
8989
else {
9090
[self parseApnsFields];
9191
_attachments = os_data[@"att"];
92-
[self parseActionButtons:os_data[@"buttons"]];
92+
93+
// it appears that in iOS 9, the 'buttons' os_data field is an object not array
94+
// this if statement checks for this condition and parses appropriately
95+
if ([os_data[@"buttons"] isKindOfClass:[NSArray class]]) {
96+
[self parseActionButtons:os_data[@"buttons"]];
97+
} else if (os_data[@"buttons"] && [os_data[@"buttons"] isKindOfClass: [NSDictionary class]] && [os_data[@"buttons"][@"o"] isKindOfClass: [NSArray class]]) {
98+
[self parseActionButtons:os_data[@"buttons"][@"o"]];
99+
}
93100
}
94101

95102
[self parseCommonOneSignalFields:_rawPayload[@"os_data"]];

0 commit comments

Comments
 (0)