1

I am facing issue in launch of particular application page when user will get push notification in ios.

is this possible to do?

if yes, can you please help me in that.

Rishi Jain
  • 13
  • 5
  • 2
    Possible duplicate of [Open a view controller when a iOS push notification is received](https://stackoverflow.com/questions/20757362/open-a-view-controller-when-a-ios-push-notification-is-received) – Luzo Nov 08 '17 at 08:13
  • By launch of application page, you mean to open the app? Elaborate... – rajtharan-g Nov 08 '17 at 08:13

1 Answers1

0

You could send a notification to yourself when you get any remote notification and by registering the UIViewController to this notification, you could open a particular UIViewController once notification is received.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{

   [[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotification" object:nil userInfo:userInfo];

}

In your FirstViewController.m register for listening to this notification.

-(void)viewDidLoad{  

      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushNotificationReceived) name:@"pushNotification" object:nil];

}

Inside the method you could open particular viewController

-(void)pushNotificationReceived{

 [self presentViewController:self.secondViewController animated:YES completion:nil];
}

Finally un-register current viewController from notification in dealloc method

-(void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];

}

Let me know if you face any problem with this.

Umang Loriya
  • 840
  • 8
  • 15