美文网首页
iOS 8显示应用角标

iOS 8显示应用角标

作者: BigPlane | 来源:发表于2015-07-25 13:17 被阅读0次

iOS 8角标显示须要用户授权,可在应用启动时请求授权:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {

    if ([[UIDevice currentDevice].systemVersion doubleValue] >= 8.0)
    {
        UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
        UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
    }
    else
    {
        UIRemoteNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:types];
    }

    return YES;
}

相关文章

网友评论

      本文标题:iOS 8显示应用角标

      本文链接:https://www.haomeiwen.com/subject/ejkmqttx.html