iOS Aurora push jumps to the specified page

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.