IOS Click on the notification bar message to jump to the specified page

Source: Internet
Author: User


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];
 }
            }
        }
    }
}


Related Article

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.