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);

    }

 

你可能感兴趣的:(ios)