3

I have implemented the push service many times even right now its working i am able to receive the notification but don't know why method below is not getting called

-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler

I googled and tried to find the solution, then I came across the things that all are already there in my code, but still I am facing this problem, I need you coders help is any thing that we could miss for this issue, Any help will be appreciated.

Ashish Kakkad
  • 23,586
  • 12
  • 103
  • 136
iShwar
  • 1,625
  • 1
  • 16
  • 31

1 Answers1

2

This method is a delegate method. So to get this called, you have to implement the delegate of UNUserNotificationCenterDelegate in the header file. If you have forgot to use delegate, place it in header file. The example below shows to place delegate for a UIViewController of name ViewController in header file:

 @interface ViewController : UIViewController<UNUserNotificationCenterDelegate>

And in the method or implementation file(ViewController.m), in its method viewDidLoad, place

self.userNotificationCenter.delegate = self;

Hope it helps :)

Rishav Chudal
  • 171
  • 1
  • 8