Skip to content

Commit

Permalink
[ios][notifications] fix: prevent initial notification being swallowe…
Browse files Browse the repository at this point in the history
…d if app is closed (expo#9478)

* [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 <[email protected]>

* Update CHANGELOG.md

Co-authored-by: Łukasz Kosmaty <[email protected]>
  • Loading branch information
cruzach and lukmccall authored Jul 31, 2020
1 parent a8c3dee commit aecca50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/expo-notifications/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit aecca50

Please sign in to comment.