The first step is familiar with pushnotification and create a certificate, you can use the following website to familiarize yourself with the following
http://blog.csdn.net/daydreamingboy/article/details/7977098 (Implementation of the simple push notification (push Notification) on iOS)
Second step, find a demo to learn: I'm looking for a demo on GitHub
Https://github.com/Turkcell/PushNotification_iOS_sdk
In the code, do the following things:
#pragma mark --------Remote Notification-(void) registerapnsnotification{//adaptation 8.0,if Walk 8.0 if (![ [Nsuserdefaults Standarduserdefaults] Boolforkey:koatosparamsdevicetoken]) {if ([[UIApplication SharedApplicati On] Respondstoselector: @selector (registerusernotificationsettings:)]) {Uiusernotificationsettings *settings = [Uiusernotificationsettings settingsfortypes:uiusernotificationtypebadge| uiusernotificationtypesound| Uiusernotificationtypealert Categories:nil]; [[UIApplication sharedapplication] registerusernotificationsettings:settings]; }else {[[uiapplication sharedapplication] registerforremotenotificationtypes:uiremotenotificationtypebadge | U Iremotenotificationtypealert | Uiremotenotificationtypesound]; } }}
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions{[self registerapnsnotification];//Clear all local notifications [application cancelalllocalnotifications]; Application.applicationiconbadgenumber = 0;}
-(void) Applicationwillterminate: (uiapplication *) application{ if ([[UIApplication sharedapplication] Enabledremotenotificationtypes] = = Uiremotenotificationtypenone &&!islogout) { [self Registerapnsnotification]; } Called when the application are about to terminate. Save data if appropriate. See also Applicationdidenterbackground:.}
Registered remote notification SUCCEEDED-(void) Application: (UIApplication *) application Didregisterforremotenotificationswithdevicetoken: ( NSData *) devicetoken{ nsstring *token = [NSString stringwithformat:@ "%@", [[[Devicetoken description] stringbyreplacingoccurrencesofstring:@ "<" withstring:@ ""] stringbyreplacingoccurrencesofstring:@ ">" withstring:@ ""]; DLog (@ "devicetoken[%@]", token); [[Nsuserdefaults Standarduserdefaults] Setobject:token Forkey:koatosparamsdevicetoken];}
Registered remote notification failed-(void) Application: (UIApplication *) application Didfailtoregisterforremotenotificationswitherror: ( Nserror *) error{ nsstring *error_str = [NSString stringWithFormat: @ "%@", error]; DLog (@ "Get Devicetoken failed [%@]", ERROR_STR);}
Ios--pushnotification Study and summary (push mechanism)