Skip to content

Commit 0d3d7dd

Browse files
committed
Fixed iOS 9 notification open handling
1 parent fe0d439 commit 0d3d7dd

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

iOS_SDK/OneSignalSDK/Source/UIApplicationDelegate+OneSignal.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,18 @@ - (void) oneSignalReceiveRemoteNotification:(UIApplication*)application UserInfo
192192
BOOL startedBackgroundJob = false;
193193

194194
if ([OneSignal appId]) {
195-
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive && userInfo[@"aps"][@"alert"])
195+
let appState = [UIApplication sharedApplication].applicationState;
196+
let isVisibleNotification = userInfo[@"aps"][@"alert"] != nil;
197+
198+
// iOS 9 - Notification was tapped on
199+
// https://medium.com/posts-from-emmerge/ios-push-notification-background-fetch-demystified-7090358bb66e
200+
// - NOTE: We do not have the extra logic for the notifiation center or double tap home button cases
201+
// of "inactive" on notification received the link above describes.
202+
// Omiting that complex logic as iOS 9 usage stats are very low (12/11/2020) and these are rare cases.
203+
if ([OneSignalHelper isIOSVersionLessThan:@"10.0"] && appState == UIApplicationStateInactive && isVisibleNotification) {
204+
[OneSignal notificationReceived:userInfo wasOpened:YES];
205+
}
206+
else if (appState == UIApplicationStateActive && isVisibleNotification)
196207
[OneSignal notificationReceived:userInfo wasOpened:NO];
197208
else
198209
startedBackgroundJob = [OneSignal receiveRemoteNotification:application UserInfo:userInfo completionHandler:callExistingSelector ? nil : completionHandler];

0 commit comments

Comments
 (0)