iOS remote push

Source: Internet
Author: User

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

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.