iOS 代码设置角标 Icon

APPDelegate添加下
由于版本更新,需要增加下判断。

if ([[UIDevice currentDevice].systemVersion doubleValue] >= 8.0)
    {
        UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
        UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
        [[UIApplication sharedApplication]setApplicationIconBadgeNumber:EmmEmiUnread];
    }
    else
    {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
        
        UIRemoteNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:types];
        [[UIApplication sharedApplication]setApplicationIconBadgeNumber:EmmEmiUnread];
        
#pragma clang diagnostic pop
    }

需要讨论的可以下边留言,欢迎一起进步!!
随手一记! ✧(≖ ◡ ≖✿)

你可能感兴趣的:(iOS 代码设置角标 Icon)