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