【发布时间】:2015-04-19 15:54:16
【问题描述】:
我不确定这是否是一个奇怪的错误,但在我的
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
我有以下代码行来请求用户权限:
// Register for Push Notitications, if running iOS 8
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
} else {
// Register for Push Notifications before iOS 8
[application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound)];
}
在模拟器上,一切正常,但在我的 iPhone 上,当我安装应用程序时,它不会要求这些权限。我已经启动了断点以确保这些行执行并且它们确实执行了。
当我进入Settings > Notifications > My App时,通知是开启的,所以系统似乎知道我之前已经授予了权限,所以它没有询问,但这似乎很奇怪。
有人见过吗?
【问题讨论】:
-
您是否尝试从您的设备上卸载该应用程序并重新安装以重置所有内容?
-
我假设stackoverflow.com/questions/12596165/… 也适用于此处:您必须重置隐私设置(或更改设备上的时间并按照评论中的说明重新启动)。
标签: ios objective-c swift