iOS Aurora push Click Push Message Jump Page

Source: Internet
Author: User

Article from: http://www.jianshu.com/p/eaf07c4372a8

Appdelegate.m

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {#if__iphone_os_version_max_allowed > __iphone_7_1if([[Uidevice currentdevice].systemversion Floatvalue] >=8.0) {[Apservice registerforremotenotificationtypes: (Uiusernotificationtypebadge| Uiusernotificationtypesound |Uiusernotificationtypealert) Categories:nil]; } Else{[Apservice registerforremotenotificationtypes: (Uiremotenotificationtypebadge| Uiremotenotificationtypesound |Uiremotenotificationtypealert)#elseCategories:nil]; [Apservice registerforremotenotificationtypes: (Uiremotenotificationtypebadge| Uiremotenotificationtypesound |Uiremotenotificationtypealert)#endifCategories:nil]; } [Apservice setupwithoption:launchoptions];if(launchoptions) {nsdictionary* Remotenotification =[Launchoptions Objectforkey:uiapplicationlaunchoptionsremotenotificationkey];//This is the decision to receive notification when the program is not running, click the notification jump page        if(remotenotification) {NSLog (@"Push Message = =%@", remotenotification);        [Self gotomssageviewcontrollerwith:remotenotification]; }    }}
-(void) Application: (UIApplication *) application didregisterusernotificationsettings: (Uiusernotificationsettings * ) notificationsettings{    [application registerforremotenotifications];}
-(void ) Application: (UIApplication *) application Didregisterforremotenotificationswithdevicetoken: (nsdata *) devicetoken{[APService    Registerdevicetoken:devicetoken]; NSLog ( @ " %@  , [nsstring stringwithformat:@"  device Token:%@    
// When Devicetoken gets a failure, the system will callback this method -(void) Application: (UIApplication *) application Didfailtoregisterforremotenotificationswitherror: (Nserror *) error{    NSLog (@ "  Devicetoken get failed, Reason:%@", error);}
//The following method is also important, here is the main processing of the message pushed over- (void) Application: (UIApplication *) application didreceiveremotenotification: (Nsdictionary *) userinfo{NSLog (@"What about the push message? ===%@", UserInfo); //obtain APNs Standard Information content, if no need can not takeNsdictionary *aps = [UserInfo valueforkey:@"APS"]; NSString*content = [APs Valueforkey:@"Alert"];//push the displayed contentNsinteger badge = [[APS Valueforkey:@"badge"] IntegerValue]; NSString*sound = [APs Valueforkey:@" Sound"];//Sounds played//Get the custom field content, UserInfo is the JSON data returned in the background, is a dictionary[Apservice Handleremotenotification:userinfo]; Application.applicationiconbadgenumber=0;    [Self gotomssageviewcontrollerwith:userinfo]; }
-(void) Applicationwillenterforeground: (uiapplication *) application {    [application Setapplicationiconbadgenumber:0];   // clear the corner label     [Application cancelalllocalnotifications];}

Here are some of the actions in the Jump page, mainly a return operation

-(void) Viewwillappear: (BOOL) animated{[Self.navigationcontroller setnavigationbarhidden:no Animated:yes];    [Super Viewwillappear:yes]; Nsuserdefaults*pushjudge =[Nsuserdefaults Standarduserdefaults]; if([[Pushjudge Objectforkey:@"Push"]isequaltostring:@"Push"]) {Self.navigationItem.leftBarButtonItem= [[Uibarbuttonitem alloc]initwithimage:[uiimage imagenamed:@"[email protected]"] Style:uibarbuttonitemstyleplain target:self action: @selector (rebacktorootviewaction)]; }Else{Self.navigationItem.leftBarButtonItem=Nil; }}
-(void) rebacktorootviewaction {    * Pushjudge = [Nsuserdefaults standarduserdefaults];    [Pushjudge setobject: @ ""forkey:@ "push"];    [Pushjudge synchronize]; // Remember to sync now     [self dismissviewcontrolleranimated:yes completion:nil];}




The code in the above 5 figures is inside the APPDELEGATE.M.

The following figure is inside the MESSAGEVC, which is the page you want to jump to.


In fact, this is very nice, it is written on the sometimes bug, you can try



The text/I called CC What's the matter (Jane book author)
Original link: http://www.jianshu.com/p/eaf07c4372a8
Copyright belongs to the author, please contact the author to obtain authorization, and Mark "book author".

iOS Aurora push Click Push Message Jump 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.