首先借鑒極客學院的教程圖
再次在蘋果開發(fā)網(wǎng)站進行配置推送證書,得到服務器和手機的證書,
1)注冊
UIUserNotificationTypenotificationTypes =UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert;
UIUserNotificationSettings*settings = [UIUserNotificationSettingssettingsForTypes:notificationTypescategories:nil];
[[UIApplicationsharedApplication]registerUserNotificationSettings:settings];
2)注冊處理
//注冊成功回調(diào)方法
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {}
//注冊失敗回調(diào)方法
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error {}
//處理本地推送
- (void)application:(UIApplication*)application didReceiveLocalNotification:(UILocalNotification*)notification {}
//處理蘋果推送