Objective c 如何使用enabledRemoteNotificationTypes更新代码,因为它是;在iOS 8中不受支持;?

Objective c 如何使用enabledRemoteNotificationTypes更新代码,因为它是;在iOS 8中不受支持;?,objective-c,iphone,apple-push-notifications,ios8,Objective C,Iphone,Apple Push Notifications,Ios8,这是我用于RemoteNotificationType的代码: NSUInteger rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; 我得到的错误是: 2014-09-29 15:46:47.416虚拟[258:21766]在iOS 8.0及更高版本中不支持enabledRemoteNotificationTypes 如果有人能给我解决方案,那将是一个很大的帮助。请使用以下方法- [[U

这是我用于RemoteNotificationType的代码:

NSUInteger rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
我得到的错误是:

2014-09-29 15:46:47.416虚拟[258:21766]在iOS 8.0及更高版本中不支持enabledRemoteNotificationTypes


如果有人能给我解决方案,那将是一个很大的帮助。

请使用以下方法-

[[UIApplication sharedApplication] isRegisteredForRemoteNotifications]


在iOS 8中检索用户启用的远程通知和用户通知设置。

使用此条件可在iOS 7和之前的iOS 8中提供支持。

#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)

NSUInteger rntypes;
  if (!SYSTEM_VERSION_LESS_THAN(@"8.0")) {
   rntypes = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];
}else{
   rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
}

您还可以使用以下代码:

if([[UIApplication sharedApplication]响应选择器:@selector(currentUserNotificationSettings)]){
UIUserNotificationType类型=[[[UIApplication sharedApplication]currentUserNotificationSettings]类型];
如果(类型==UIUserNotificationTypeNone){
//做点什么
}
}否则{
UIRemoteNotificationType=[[UIApplication sharedApplication]EnabledRemoteNotificationType];
如果(类型==UIRemoteNotificationTypeNone){
//做点什么
}
}
或者,如果您只想检查用户是否已注册远程通知,请选择此选项:

if ([[UIApplication sharedApplication] respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) {

    BOOL isRegisteredForRemoteNotifications = [[UIApplication sharedApplication] isRegisteredForRemoteNotifications];

    if (isRegisteredForRemoteNotifications) { 
        // Do something
    }

} else {

    UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

    if (types == UIRemoteNotificationTypeNone) {
        // Do something
    }
}
这个怎么样?
if ([[UIApplication sharedApplication] respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) {

    BOOL isRegisteredForRemoteNotifications = [[UIApplication sharedApplication] isRegisteredForRemoteNotifications];

    if (isRegisteredForRemoteNotifications) { 
        // Do something
    }

} else {

    UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

    if (types == UIRemoteNotificationTypeNone) {
        // Do something
    }
}