我有一个使用以下代码启用推送通知的 iOS 应用程序
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
// iOS 8 Notifications
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[application registerForRemoteNotifications];
}
else
{
// iOS < 8 Notifications
[application registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
}
当这个应用程序在 iOS9 设备上运行时,它一开始就要求权限,但在 iOS7 和 iPhone 4 上使用时,它不会要求权限,但它接收到通知就好了,无法理解问题。