To initialize the SDK first, the official document has
[Jpushservice registerforremotenotificationtypes: (Uiusernotificationtypebadge | Uiusernotificationtypesound | Uiusernotificationtypealert) Categories:nil];
[Jpushservice setupwithoption:launchoptions appkey:@ "" channel:@ "Publish Channel" apsforproduction:no];
Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (5.0f * nsec_per_sec)), Dispatch_get_main_queue (), ^{
Alias needs to look at its own actual value assignment
[Jpushservice settags:nil alias:nil fetchcompletionhandle:^ (int irescode, Nsset *itags, NSString *iAlias) {
}];
});
Adding Methods in Appdelegate
-(void) Application: (UIApplication *) application
Didreceiveremotenotification: (nsdictionary *) userInfo
Fetchcompletionhandler: (void (^) (uibackgroundfetchresult)) Completionhandler {
[Jpushservice Handleremotenotification:userinfo];
NSLog (@ "userinfo%@", userInfo);
Completionhandler (Uibackgroundfetchresultnewdata);
if (application.applicationstate = = uiapplicationstateactive) {
Here to write the app is running, push over message processing
} else if (application.applicationstate = = uiapplicationstateinactive) {
The app runs in the background and pushes over the processing of messages
[Self gotomssageviewcontrollerwith:userinfo];
} else if (application.applicationstate = = Uiapplicationstatebackground) {
App not running, push over message processing
[Self gotomssageviewcontrollerwith:userinfo];
}
}
Jump method
-(void) Gotomssageviewcontrollerwith: (nsdictionary*) msgdic{
Save the field locally and use it to determine the page you want to jump to
Nsuserdefaults*pushjudge = [Nsuserdefaults standarduserdefaults];
[Pushjudge setobject:@ "Push" forkey:@ "push"];
[Pushjudge Synchronize];
if ([msgdic[@ "type"]isequaltostring:@ "Notification_cabinet"]) {
Here write the controller to jump
Userorderlistviewcontroller * VC = [[Userorderlistviewcontroller alloc]init];
Uinavigationcontroller * Nav = [[Uinavigationcontroller ALLOC]INITWITHROOTVIEWCONTROLLER:VC];
[Self.window.rootViewController PresentViewController:Navanimated:YES Completion:nil];
} else if ([msgdic[@ "type"]isequaltostring:@ "Message_notice"]) {
Recommendviewcontroller *VC = [[Recommendviewcontroller alloc] init];
Uinavigationcontroller * Nav = [[Uinavigationcontroller ALLOC]INITWITHROOTVIEWCONTROLLER:VC];
[Self.window.rootViewControllerpresentViewController:Nav Animated:yes Completion:nil];
}
}
Add the Viewdidload method to the page you want to jump to
Nsuserdefaults*pushjudge = [Nsuserdefaults standarduserdefaults];
if ([[[pushjudgeobjectforkey:@] "push"]isequaltostring:@ "push"]) {
[Self.navigationcontroller SetNavigationBarHidden:NOanimated:YES];
Self.navigationItem.leftBarButtonItem = [[Uibarbuttonitem alloc] initwithimage:[uiimage imagenamed:@ ""]style: Uibarbuttonitemstyleplain target:selfaction: @selector (rebacktorootviewaction)];
}
The specific situation according to your own app needs to modify
iOS Aurora push jumps to the specified page