IOS8下发送本地通知注意事项

IOS8下发送本地通知需要进行注册,否则无法正常使用。

在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 方法下添加如下代码:

?

if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){
    UIUserNotificationType type = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound;
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:type categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}


你可能感兴趣的:(IOS8下发送本地通知注意事项)