IOS badgeValue和applicationIconBadgeNumber

- (void)getUnreadCount
{
    NSUInteger count = [self.home.tabBarItem.badgeValue integerValue];
    count = count + 1;
    self.home.tabBarItem.badgeValue = [NSString stringWithFormat:@"%ld",count];
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
    
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    [UIApplication sharedApplication].applicationIconBadgeNumber = count;
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
    //后台开启任务让程序保持运行状态
    [application beginBackgroundTaskWithExpirationHandler:^{
        
    }];
}

后台中设置保持迟勋运行状态


你可能感兴趣的:(ios,badgeValue)