[UIApplication sharedApplication].applicationIconBadgeNumber 不更新徽章
[UIApplication sharedApplication].applicationIconBadgeNumber does not update badge
我的一个应用程序中有一个特殊的电台。我还应该打电话给:
[UIApplication sharedApplication].applicationIconBadgeNumber=<value>
徽章一直不显示。
在我经常调用的应用程序委托的 didFinishLaunchingWithOptions
中:
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound) categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
我也试过通过通知的方式设置,但是显示了通知,但徽章没有更新。
可能是什么问题,或者我怎样才能更好地了解?
首先注册UIUserNotificationSettings
UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
[UIApplication sharedApplication].applicationIconBadgeNumber = <value>;
这要容易得多。显然 iOS 在更新后从应用程序设置中删除了 "show badge icon"。一旦启用徽章更新正确。无论如何感谢您的支持。
我的一个应用程序中有一个特殊的电台。我还应该打电话给:
[UIApplication sharedApplication].applicationIconBadgeNumber=<value>
徽章一直不显示。
在我经常调用的应用程序委托的 didFinishLaunchingWithOptions
中:
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound) categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
我也试过通过通知的方式设置,但是显示了通知,但徽章没有更新。 可能是什么问题,或者我怎样才能更好地了解?
首先注册UIUserNotificationSettings
UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
[UIApplication sharedApplication].applicationIconBadgeNumber = <value>;
这要容易得多。显然 iOS 在更新后从应用程序设置中删除了 "show badge icon"。一旦启用徽章更新正确。无论如何感谢您的支持。