Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(ios): edge case when non-interactive notification is tapped
  • Loading branch information
mvayngrib committed Apr 3, 2019
commit dffaa859655ff43d03376ef600817ddc5cd82c1d
22 changes: 20 additions & 2 deletions RNNotifications/RNNotifications.m
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,26 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNot
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
{
NSString* identifier = response.actionIdentifier;
NSDictionary* userInfo = response.notification.request.content.userInfo;
if ([identifier isEqualToString:UNNotificationDefaultActionIdentifier]) {
if ([RNNotificationsBridgeQueue sharedInstance].jsIsReady) {
dispatch_async(dispatch_get_main_queue(), ^{
[self checkAndSendEvent:RNNotificationOpened body:userInfo];
});
} else {
[[RNNotificationsBridgeQueue sharedInstance] postNotification:userInfo];
}

completionHandler();
return;
}

// TODO: emit this
// if ([identifier isEqualToString:UNNotificationDismissActionIdentifier]) {
// [self checkAndSendEvent:RNNotificationDismissed body:userInfo];
// return;
// }

NSString* completionKey = [NSString stringWithFormat:@"%@.%@", identifier, [NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]]];
NSMutableDictionary* info = [[NSMutableDictionary alloc] initWithDictionary:@{ @"identifier": identifier, @"completionKey": completionKey }];

Expand All @@ -250,8 +270,6 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNoti
info[@"text"] = text;
}

NSDictionary* userInfo = response.notification.request.content.userInfo;

// add notification custom data
if (userInfo != NULL) {
info[@"notification"] = userInfo;
Expand Down