现在的位置: 首页 > 综合 > 正文

ios8推送问题

2017年11月30日 ⁄ 综合 ⁄ 共 886字 ⁄ 字号 评论关闭

ios8推送问题

registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings 
     settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)      
categories:nil]];


    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
//这里还是原来的代码
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}

判断PUSH是否打开

{
UIRemoteNotificationType types;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
   {
 types = [[UIApplication sharedApplication] currentUserNotificationSettings].types;
    }
else
   {
 types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
    }


return (types & UIRemoteNotificationTypeAlert);
}
【上篇】
【下篇】

抱歉!评论已关闭.