iOS 8.更改应用程序徽章编号,不另行通知 [英] iOS 8. Change app badge number without any notifications

查看:172
本文介绍了iOS 8.更改应用程序徽章编号,不另行通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,我需要在应用图标上设置徽章,并为此徽章设置数字。问题是我需要注册这样的用户通知设置:

In my app I need to set badge onto the app icon and set numbers for this badge. The problem is that I need to register user notification settings like this:

if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
{
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil]];
}

以使其在iOS8上运行。如果我运行此代码,那么在启动系统上会向用户显示一条警告,其中包含: ApplicationName希望向您发送通知。通知可能包括bla la bla 。这是标准的,我相信你已经看过很多次了。仅仅因为我注册了通知设置,系统认为我的应用程序将发布一些通知。但事实并非如此!我不想发布通知。我想做的就是在这个徽章上设置徽标到图标和数字。是否有可能在iOS 8上实现此功能而无需注册用户通知或注册但未显示系统警报?任何想法,伙计们?

in order to make it work on iOS8. If I run this code then on start system presents an alert to the user which says something like:ApplicationName would like to send you notifications. Notifications may include bla la bla. It's the standard one, I'm sure you've seen it many times. Just because I registered notification settings the system thinks my app is going to post some notifications. But it's not! I don't want to post notifications. All I wanna do is to set badge onto the icon and a number onto this badge. Is there any possibility to achieve this on iOS 8 without registering user notifications or registering but not showing that system alert? Any ideas, guys?

推荐答案

关于这一点,文档是明确的,在iOS8及更高版本中,您必须注册用户通知:

The documentation is explicit on that point, on iOS8 and later, you have to register for user notifications :

@property(nonatomic)NSInteger applicationIconBadgeNumber; //设置为0隐藏。默认值为0.在iOS 8.0及更高版本中,您的应用程序必须使用 - [UIApplication registerUserNotificationSettings:]注册用户通知才能设置图标徽章。

这篇关于iOS 8.更改应用程序徽章编号,不另行通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆