1.//Register the Remote Notification Service (the first time you register the service will pop up a reminder box, let the user authorization)
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions{//Registering a Remote Notification service (the first time you sign up for a service will pop up a reminder box to allow the user to authorize)[Application Registerforremotenotificationtypes:uiremotenotificationtypebadge | Uiremotenotificationtypesound |Uiremotenotificationtypealert];
Add a label to check the startup mode UILabel*label =[[UILabel alloc] init]; Label.backgroundcolor=[Uicolor Lightgraycolor]; Label.frame= CGRectMake (0, -, the, -); Label.font= [Uifont systemfontofsize: the]; Label.numberoflines=0; [Self.window.rootViewController.view Addsubview:label]; Nsdictionary*userinfo =Launchoptions[uiapplicationlaunchoptionsremotenotificationkey]; if(userInfo) {Label.text=[userInfo description]; } Else{Label.text=@"directly click on the app icon to launch the program"; } returnYES;}
2. Get the Devicetoken of your device
-(void) Application: (UIApplication *) application Didregisterforremotenotificationswithdevicetoken: ( NSData *) devicetoken{ NSLog (@ " registered remote notification success----%@", Devicetoken); /* * 1. Send Devicetoken to the company's server c330833f 248c4fed e87068b6 c4b90ee8 a2b57119 aac2b93d 3f2eb27f e7d44c8c c330833f 248c4fed e87068b6 c4b90ee8 a2b57119 aac2b93d 3f2eb27f e7d44c8c}
3. When a remote push notification is received, it is called
-(void) Application: (UIApplication *) application didreceiveremotenotification: (nsdictionary *) userInfo{
Read some of the contents of the remote notification here NSLog (@ "Receive remote notification--%@", userinfo[@ "UserInfo"]);}
iOS remote push