From aecca502620abc6ea324051b67ff8e93c19da907 Mon Sep 17 00:00:00 2001 From: Charlie Cruzan <35579283+cruzach@users.noreply.github.com> Date: Fri, 31 Jul 2020 13:21:58 -0400 Subject: [PATCH] [ios][notifications] fix: prevent initial notification being swallowed if app is closed (#9478) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [ios][notifications] fix: EXUserNotificationManager swallowing initial notification when app killed * revert previous change, add check for EXUserNotificationManager * remove extra space Co-authored-by: Łukasz Kosmaty * Update CHANGELOG.md Co-authored-by: Łukasz Kosmaty --- packages/expo-notifications/CHANGELOG.md | 2 ++ .../Notifications/EXNotificationCenterDelegate.m | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/expo-notifications/CHANGELOG.md b/packages/expo-notifications/CHANGELOG.md index 37d51f2da5184d..9a53a58b6969ba 100644 --- a/packages/expo-notifications/CHANGELOG.md +++ b/packages/expo-notifications/CHANGELOG.md @@ -8,6 +8,8 @@ ### 🐛 Bug fixes +- Fixed notification response listener not triggering in the managed workflow on iOS when app was completely killed ([#9478](https://github.com/expo/expo/pull/9478) by [@cruzach](https://github.com/cruzach)) + ## 0.6.0 — 2020-07-29 ### 🎉 New features diff --git a/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m b/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m index 644c297e3c3915..adfd3651b1d000 100644 --- a/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m +++ b/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m @@ -124,18 +124,18 @@ __block void (^completionHandlerCaller)(void) = ^{ - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { // Save response to pending responses array if none of the handlers will handle it. - BOOL responseWillBeHandledByAnyDelegate = NO; + BOOL responseWillBeHandledByAppropriateDelegate = NO; for (int i = 0; i < _delegates.count; i++) { id pointer = [_delegates pointerAtIndex:i]; - if ([pointer respondsToSelector:@selector(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)]) { - responseWillBeHandledByAnyDelegate = YES; + if ([pointer respondsToSelector:@selector(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)] + && ![NSStringFromClass([pointer class]) isEqual: @"EXUserNotificationManager"]) { + // Remove EXUserNotificationManager check when LegacyNotifications are no longer supported + responseWillBeHandledByAppropriateDelegate = YES; break; } } - if (!responseWillBeHandledByAnyDelegate) { + if (!responseWillBeHandledByAppropriateDelegate) { [_pendingNotificationResponses addObject:response]; - completionHandler(); - return; } __block int delegatesCalled = 0;