iOS8远程通知处理

// IOS8 新系统需要使用新的代码注册推送
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是否打开的方法是:

 //判断推送是否开启

    if (isiOS8)

    {

        UIUserNotificationType type = [application currentUserNotificationSettings].types;

        if (type) {

        }else

        {

        }

         NSLog(@"------- 推送类型 ------%d",type);

    }

    else

    {

       UIRemoteNotificationType type = [application enabledRemoteNotificationTypes];

        if (type) {

        }else

        {

   }

         NSLog(@"------- 推送类型 ------%d",type);

    }

 

posted on 2014-09-22 14:50  助金  阅读(316)  评论(0编辑  收藏  举报