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
Ivan authored and Ivan committed May 15, 2020
1 parent 53ba717 commit 7b7893f
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 @@ -125,6 +125,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"] = @"1";

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

return formattedNotification;
}

#endif //TARGET_OS_TV / TARGET_OS_UIKITFORMAC

RCT_EXPORT_MODULE()
Expand Down Expand Up @@ -220,7 +234,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 7b7893f

Please sign in to comment.