gpt4 book ai didi

objective-c - registerForRemoteNotificationTypes : is not supported in iOS 8. 0 及更高版本

转载 作者:IT老高 更新时间:2023-10-28 12:14:59 26 4
gpt4 key购买 nike

在 iOS 8.x 下尝试注册推送通知时:

application.registerForRemoteNotificationTypes(UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound)

我收到以下错误:

registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.

任何想法什么是做它的新方法?当我在 iOS 7.x 上运行这个 Swift 应用程序时,它确实有效。

编辑

在 iOS 7.x 上,当我包含我得到的条件代码时(SystemVersion 条件或 #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000)

dyld: Symbol not found: _OBJC_CLASS_$_UIUserNotificationSettings

最佳答案

对于 iOS<10

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
//-- Set Notification
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)];
}

//--- your custom code
return YES;
}

适用于 iOS10

https://stackoverflow.com/a/39383027/3560390

关于objective-c - registerForRemoteNotificationTypes : is not supported in iOS 8. 0 及更高版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24454033/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com