在iOS8上registerUserNotificationSettings的奇怪行为 [英] Strange behavior of registerUserNotificationSettings in iOS8

查看:142
本文介绍了在iOS8上registerUserNotificationSettings的奇怪行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

致电

UIUserNotificationType types = UIUserNotificationTypeAlert;

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil];

[[UIApplication sharedApplication] registerUserNotificationSettings:settings];

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings

我永久得到所有类型的 notificationSettings

<UIUserNotificationSettings: 0x16dd6160; types: (UIUserNotificationTypeAlert UIUserNotificationTypeBadge UIUserNotificationTypeSound);>

UIUserNotificationSettings *settings = [[UIApplication sharedApplication] currentUserNotificationSettings]

给我同样的各类尽管我唯一的警报类型的初步选择。

gives me the same all types despite my initial choice of the only alert type.

所以我不能设置上开始限制动力的权限。

So I can't setup restricted dynamical permissions on start.

有没有关于在互联网上类似问题的任何信息。

There is no any information about similar problems in the internet.

推荐答案

看来,这是不可能的iOS8上设置 UserNotificationType 从应用程序(至少)。人们需要使用一般的通知中心设置声音,徽章和警报的任意组合。仅注册这第一次尝试用推送通知的权限警惕发生套 UserNotificationType 必要的。

It seems that it is impossible to setup UserNotificationType from application in iOS8 (at least). One needs to use general Notification Center to set any combination of sound, badge and alert. Only the first attempt to register which occurs with Push notification permissions alert sets UserNotificationType needed.

另一种方式是发送 UserNotificationType 上订阅推送服务​​器负载取决于这种类型的应该做。

Another way is to send UserNotificationType on subscription to your push server which should make payload depending of this type.

这篇关于在iOS8上registerUserNotificationSettings的奇怪行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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