Skip to content

Commit

Permalink
Add userInteraction attr for user opened push
Browse files Browse the repository at this point in the history
  • Loading branch information
xvonabur committed Sep 11, 2020
1 parent e3375bf commit b1a1c9e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion ios/RNCPushNotificationIOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ @implementation RNCPushNotificationIOS
return formattedNotification;
}

API_AVAILABLE(ios(10.0))
static NSDictionary *RCTFormatOpenedUNNotification(UNNotification *notification)
{
NSMutableDictionary *formattedNotification = [RCTFormatUNNotification(notification) mutableCopy];
UNNotificationContent *content = notification.request.content;

NSMutableDictionary *userInfo = [content.userInfo mutableCopy];
userInfo[@"userInteraction"] = [NSNumber numberWithInt:1];

formattedNotification[@"userInfo"] = RCTNullIfNil(RCTJSONClean(userInfo));

return formattedNotification;
}

#endif //TARGET_OS_TV / TARGET_OS_UIKITFORMAC

RCT_EXPORT_MODULE()
Expand Down Expand Up @@ -222,7 +236,7 @@ + (void)didReceiveNotificationResponse:(UNNotificationResponse *)response
API_AVAILABLE(ios(10.0)) {
[[NSNotificationCenter defaultCenter] postNotificationName:kLocalNotificationReceived
object:self
userInfo:RCTFormatUNNotification(response.notification)];
userInfo:RCTFormatOpenedUNNotification(response.notification)];
}

- (void)handleLocalNotificationReceived:(NSNotification *)notification
Expand Down

0 comments on commit b1a1c9e

Please sign in to comment.