This is divided into 3 different cases.
1. When the app is off, click on the notification bar message to jump to the specified page
2. When the app is running in the background, click on the notification bar message to jump to the specified page
3. When the app is running in the background, there will be no notification bar reminders and will not jump to the specified interface
For the treatment of 1.
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions
{
[self jumptoviewcontroller:launchoptions];
Return YES
}
#pragma mark-page Jump
-(void) Jumpviewcontroller: (nsdictionary*) tfdic
{
nsdictionary *remotenotification = [Tfdic Objectforkey:uiapplicationlaunchoptionsremotenotificationkey];
if ([Chpainterface Isuserlogin])
{for
(NSString *tfstr in remotenotification)
{
if ([Tfstr isequaltostring:@ "Careline"])
{
Viewcontroller *_viewcontroller = [[Viewcontroller alloc]init];
[_viewcontroller loadapnsinfodic:remotenotification];
Uinavigationcontroller *nav= (Uinavigationcontroller *) Self.window.rootViewController;
[Nav pushviewcontroller:_viewcontroller Animated:yes]}}}
For the treatment of 2.
-(void) Application: (UIApplication *) application didreceiveremotenotification: (Nsdictionary *) UserInfo {//
When the app is running in the foreground, do not process if ([uiapplication sharedapplication].applicationstate = = uiapplicationstateactive) {} When the app is running in the background, when there is a notification bar message, click on it, and it will execute the following method to jump to the corresponding page else if ([uiapplication sharedapplication].applicationstate = = Uiappl
icationstateinactive) {if ([Chpatyinterface Isuserlogin]) {NSLog (@ "received push:%@", userInfo);
For (NSString *tfstr in UserInfo) {if ([Tfstr isequaltostring:@ "Careline"])
{Viewcontroller *_viewcontroller = [[Viewcontroller alloc]init];
[_viewcontroller Loadapnsinfodic:userinfo];
Uinavigationcontroller *nav= (Uinavigationcontroller *) Self.window.rootViewController;
[Nav Pushviewcontroller:_viewcontroller Animated:yes];
}
}
}
}
}