首先借鉴极客学院的教程图
再次在苹果开发网站进行配置推送证书,得到服务器和手机的证书,
1)注册
UIUserNotificationTypenotificationTypes =UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert;
UIUserNotificationSettings*settings = [UIUserNotificationSettingssettingsForTypes:notificationTypescategories:nil];
[[UIApplicationsharedApplication]registerUserNotificationSettings:settings];
2)注册处理
//注册成功回调方法
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {}
//注册失败回调方法
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error {}
//处理本地推送
- (void)application:(UIApplication*)application didReceiveLocalNotification:(UILocalNotification*)notification {}
//处理苹果推送