[UIApplication sharedApplication] .applicationIconBadgeNumber不会更新徽章

时间:2016-04-04 10:37:43

标签: ios notifications badge

我的一个应用程序中有一个特殊的站点。 Alt我应该打电话:

[UIApplication sharedApplication].applicationIconBadgeNumber=<value>

徽章不会显示。 在app委托的didFinishLaunchingWithOptions我经常打电话:

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert  |   UIUserNotificationTypeBadge | UIUserNotificationTypeSound) categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];

我还尝试通过通知设置它,但是会显示通知但徽章未更新。 可能是什么问题或者我怎么能更好地了解?

2 个答案:

答案 0 :(得分:0)

首先注册UIUserNotificationSettings

UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge categories:nil];

[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];

[UIApplication sharedApplication].applicationIconBadgeNumber = <value>;

答案 1 :(得分:0)

这要容易得多。显然,iOS上的更新删除了&#34;显示徽章图标&#34;从应用程序设置。启用后,徽章会正确更新。无论如何,谢谢你的支持。