File tree Expand file tree Collapse file tree 4 files changed +26
-1
lines changed Expand file tree Collapse file tree 4 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -102,11 +102,20 @@ fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
102102{
103103 [ RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError: error ] ;
104104}
105- // Required for the localNotification event.
105+ // IOS 10+ Required for localNotification event
106+ - (void )userNotificationCenter:(UNUserNotificationCenter *)center
107+ didReceiveNotificationResponse:(UNNotificationResponse *)response
108+ withCompletionHandler:(void (^)(void ))completionHandler
109+ {
110+ [ RNCPushNotificationIOS didReceiveNotificationResponse: response ] ;
111+ completionHandler ();
112+ }
113+ // IOS 4-10 Required for the localNotification event.
106114- (void )application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
107115{
108116 [ RNCPushNotificationIOS didReceiveLocalNotification: notification ] ;
109117}
118+
110119```
111120
112121Also, if not already present, at the top of the file:
Original file line number Diff line number Diff line change @@ -69,6 +69,14 @@ - (void)application:(UIApplication *)application didReceiveLocalNotification:(UI
6969{
7070 [RNCPushNotificationIOS didReceiveLocalNotification: notification];
7171}
72+ // IOS 10+ Required for local notification tapped event
73+ - (void )userNotificationCenter : (UNUserNotificationCenter *)center
74+ didReceiveNotificationResponse : (UNNotificationResponse *)response
75+ withCompletionHandler : (void (^)(void ))completionHandler
76+ {
77+ [RNCPushNotificationIOS didReceiveNotificationResponse: response];
78+ completionHandler ();
79+ }
7280
7381- (NSURL *)sourceURLForBridge : (RCTBridge *)bridge
7482{
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ typedef void (^RNCRemoteNotificationCallback)(UIBackgroundFetchResult result);
1919+ (void )didReceiveRemoteNotification : (NSDictionary *)notification ;
2020+ (void )didReceiveRemoteNotification : (NSDictionary *)notification fetchCompletionHandler : (RNCRemoteNotificationCallback)completionHandler ;
2121+ (void )didReceiveLocalNotification : (UILocalNotification *)notification ;
22+ + (void )didReceiveNotificationResponse : (UNNotificationResponse *)response API_AVAILABLE(ios(10.0 ));
2223+ (void )didFailToRegisterForRemoteNotificationsWithError : (NSError *)error ;
2324#endif
2425
Original file line number Diff line number Diff line change @@ -216,6 +216,13 @@ + (void)didReceiveLocalNotification:(UILocalNotification *)notification
216216 userInfo: RCTFormatLocalNotification (notification)];
217217}
218218
219+ + (void )didReceiveNotificationResponse : (UNNotificationResponse *)response
220+ API_AVAILABLE(ios(10.0 )) {
221+ [[NSNotificationCenter defaultCenter ] postNotificationName: kLocalNotificationReceived
222+ object: self
223+ userInfo: RCTFormatUNNotification (response.notification)];
224+ }
225+
219226- (void )handleLocalNotificationReceived : (NSNotification *)notification
220227{
221228 [self sendEventWithName: @" localNotificationReceived" body: notification.userInfo];
You can’t perform that action at this time.
0 commit comments