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