APNs Remote Push

Source: Internet
Author: User

APNs Remote Push

Generate a push certificate

1. Login to the developer Center : https://developer.apple.com

2. Point Open certificates identifiers and proversionprofiles inside

3. Create a APPID. Tick Push Notification Servers Service

4. Search for the APPID you just created , Click Edit, Configure the certificate , download double-click

5. Certificate creation completed, right-click in key chain to export P12

1.App Key

2. Real- machine testing

Note: The implementation of push messages can only be implemented in the real machine

Add frame and Aurora push APService.h and SDK (can download Jpush Demo in Aurora push)

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {//Override point for customization after application launch.[Apservice registerforremotenotificationtypes: (Uiusernotificationtypebadge| uiusernotificationtypesound|Uiusernotificationtypealert) Categories:nil];    [Apservice setupwithoption:launchoptions]; returnYES;}- (void) Application: (UIApplication *) application Didregisterforremotenotificationswithdevicetoken: (NSData *) Devicetoken {NSLog (@"%@", Devicetoken); [Apservice Registerdevicetoken:devicetoken];}- (void) Application: (UIApplication *) Applicationdidreceiveremotenotification: (Nsdictionary*) UserInfo {//Required[Apservice handleremotenotification:userinfo];}- (void) Application: (UIApplication *) Applicationdidreceiveremotenotification: (Nsdictionary*) Userinfofetchcompletionhandler: (void                        (^) (Uibackgroundfetchresult)) Completionhandler {[Apservice handleremotenotification:userinfo];    Completionhandler (Uibackgroundfetchresultnewdata); NSLog (@"Receive notification:%@", UserInfo); Viewcontroller*VC =[[Viewcontroller alloc] init]; VC.string= userinfo[@"APS"][@"Alert"]; NSLog (@"S:%@"Vc.string); [[Nsnotificationcenter Defaultcenter] POSTNOTIFICATIONNAME:VC.string Object: Nil UserInfo:@"Str"];}- (void) Application: (UIApplication *) Applicationdidfailtoregisterforremotenotificationswitherror: (Nserror*) Error {NSLog (@"Did Fail to Register for Remote notifications with Error:%@", error);}-(NSString *) Logdic: (Nsdictionary *) dic {if(![dic Count]) {        returnNil; } nsstring*TEMPSTR1 =[[dic description] stringbyreplacingoccurrencesofstring:@"\\u"withstring:@"\\u"]; NSString*TEMPSTR2 =[tempStr1 stringbyreplacingoccurrencesofstring:@"\ "" Withstring:@"\\\""]; NSString*TEMPSTR3 =    [[@"\ "" STRINGBYAPPENDINGSTRING:TEMPSTR2] stringbyappendingstring:@"\""]; NSData*tempdata =[TempStr3 datausingencoding:nsutf8stringencoding]; NSString*str =[Nspropertylistserialization propertylistfromdata:tempdata Mutabilityoption:ns Propertylistimmutable Format:null Errord    Escription:null]; NSLog (@"Str%@", str); returnstr;}

APNs 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.