我不确定这是否是一个奇怪的 bug,但在我的
- (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上安装应用程序时,它不会询问这些权限。我已经设置了断点以确保代码行得到执行。
当我进入“设置>通知>我的应用程序”时,通知是开启的,所以系统似乎知道我之前已经授予权限,因此不需要再次询问,但这似乎很奇怪。
有人之前看到过这种情况吗?