Summary of iOS message pushes

Source: Internet
Author: User

When the app does not start , it receives a message notification . This time the operating system will display an alert by default , marking a number on the app icon

1When a push message is received when the program is turned off, tapping the icon or message Bar invokes-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) Launchoptions2when the program is in the foreground, the message push will call- (void) Application: (UIApplication *) application didreceiveremotenotification: (Nsdictionary *) UserInfo3when the program is running in the background, if you receive a message push, clicking on the icon or the message bar will call- (void) Application: (UIApplication *) application didreceiveremotenotification: (Nsdictionary *) UserInfo for 1 case Codes if(launchoptions) {nsdictionary* Pushinfo = [launchoptions objectforkey:@"Uiapplicationlaunchoptionsremotenotificationkey"]; //This must be converted with stringWithFormat        if(Pushinfo! =Nil) {Uialertview*alert = [[Uialertview alloc]initwithtitle:@"app off"Message:[nsstring stringWithFormat:@"%@", Pushinfo]Delegate: Self Cancelbuttontitle:@"OK"Otherbuttontitles:nil, nil];        [Alert show]; }} for 2, 3 case codes if([[UserInfo Objectforkey:@"APS"] Objectforkey:@"Alert"]!=NULL) {        //when the program is in the foreground, if you receive a message push processing        if(Application.applicationstate = =uiapplicationstateactive) {Uialertview*alert = [[Uialertview alloc]initwithtitle:@"app foreground Run"Message:[[userinfo Objectforkey:@"APS"] Objectforkey:@"Alert"]Delegate: Self Cancelbuttontitle:@"Determine"Otherbuttontitles:nil, nil];        [Alert show]; }        Else  //When the program is running in the background, you receive a message push processing{Uialertview*alert = [[Uialertview alloc]initwithtitle:@"app background Run"Message:[nsstring stringWithFormat:@"%@", UserInfo]Delegate: Self Cancelbuttontitle:@"OK"Otherbuttontitles:nil, nil];                    [Alert show]; }    }

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.