ReactNative iOS UNUserNotificationCenter: implement didReceiveNotificationResponse

Viewed 535

I'm building React Native application and use scheduleLocalNotifications. Inside the notification handler, I navigate the user to the particular screen inside an app. It was working fine before OneSignal integration. After as I understand now I need to implement UNUserNotificationCenter delegate to handle notification clicks. I did that, but when I open the notification I receive the warning that says

App[134:16879] Warning: UNUserNotificationCenter delegate received call to -userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: but the completion handler was never called.

and the handler is not called.

Here's what I did.

I have my AppDelegate.h with the following code:

...
#import <UserNotifications/UserNotifications.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>
...

Then, inside AppDelegate.m, I implemented the following method:

- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response  withCompletionHandler:(void (^)(void))completionHandler   {
  NSLog( @"for handling push in background" );
}

and added this code to didFinishLaunchingWithOptions:

...
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  center.delegate = self;
...

Can't understand what do I miss here.

0 Answers
Related