需要为iOS版本小于8.0的registerUserNotificationSettings进行更改

时间:2014-10-17 10:05:22

标签: ios uilocalnotification

我需要代码在iOS版本低于8.0的应用程序中注册UserNotificationSettings。

我在iOS 8.0中使用了以下内容:

[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];

1 个答案:

答案 0 :(得分:1)

您需要检查应用是否包含该方法(选择器)。

if([application respondsToSelector:@selector(registerUserNotificationSettings:)])
{
    [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge  | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil]];
}