ios (推送之遠(yuǎn)程推送)升級(jí)成ios8系統(tǒng)之后有些程序接收不到遠(yuǎn)程推送
來(lái)源:程序員人生 發(fā)布時(shí)間:2015-02-03 08:45:54 閱讀次數(shù):3375次
保護(hù)1個(gè)程序,當(dāng)手機(jī)升級(jí)到ios8以后就不能接收到遠(yuǎn)程推送,顯示注冊(cè)失敗,查了下資料,原來(lái)是沒有獲得用戶許可,加了個(gè)方法試了下,ok
if ([[[UIDevice currentDevice]systemVersion ]integerValue] >= 8) {
UIUserNotificationSettings*setting = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil];
[application registerUserNotificationSettings:setting];
[application registerForRemoteNotifications];
}else{
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound];
}
系統(tǒng)版本不同所用的注冊(cè)方法也是不1樣的,下面是蘋果sdk給出的說明:
- (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types NS_DEPRECATED_IOS(3_0, 8_0, <span style="color:#FF0000;">"Please use registerForRemoteNotifications and registerUserNotificationSettings: instead"</span>);
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)