使用未声明的标识符'UIUserNotificationSettings'。

5

我正在尝试使用Xcode 6编译现有应用程序。

以下是我的代码:

UIUserNotificationSettings *settings = [UIApplication.sharedApplication currentUserNotificationSettings];

这是我的错误:
use of undeclared identifier 'UIUserNotificationSettings'

我不知道如何解决这个问题。

这是我的iOS 8检查:

if (SYSTEM_VERSION_LESS_THAN(_iOS_8_0)) {

        // Displaying notifications and ringing

        if ([self isMissingMandatoryNotificationTypes:[UIApplication.sharedApplication enabledRemoteNotificationTypes]]) {

            [self registrationWithSuccess:^{
                DDLogInfo(@"Push notifications were succesfully re-enabled");
            } failure:^{
                [self.missingPermissionsAlertView show];
            }];
        }

    } else {

        // UIUserNotificationsSettings
        UIUserNotificationSettings *settings = [UIApplication.sharedApplication currentUserNotificationSettings];

你的应用是为iOS8设计的吗? - Larme
你改变了部署目标吗? - n00bProgrammer
1个回答

9
让它变成这样:
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000

UIUserNotificationSettings *settings = [UIApplication.sharedApplication currentUserNotificationSettings];

#endif

完美!正是我所需要的。 - Aleks
对我来说,这在使用Xcode 5.1.1和iPhone版本8.1.1时没有起作用。 - liv a

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接