gpt4 book ai didi

ios - 部署目标 iOS8 但希望支持 iOS7 - 弃用警告

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:15:39 25 4
gpt4 key购买 nike

我有一个应用程序,我想以新的 iOS 8.1 为目标,但我也希望拥有 iOS 7 的人能够使用我的应用程序。因此,例如对于我的推送通知,在我的应用程序委托(delegate)中我有

    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)];
}

要为 iOS 8 和 iOS 7 打开推送通知,但是当我更改我的部署目标时,我收到警告说这已被弃用:

[application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound)];

处理此问题的最佳方法是什么?对于提交到应用商店以及我个人而言,我不喜欢在我的代码中看到警告。

提前感谢您的帮助。

编辑

这是一张警告图片 我看到我的部署目标是 iOS8.1 并且不确定在哪里可以找到我的基础 SDK?这是图片:

enter image description here enter image description here enter image description here enter image description here

最佳答案

按照 orkenstein 所述更改您的代码:

if ([application respondsToSelector:@selector(registerForRemoteNotificationTypes:)])
{

UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
}
else
{
[application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound)];
}

接下来调整你的build设置
将基础 SDK 设置为最新:

Screenshot from Settings showing base SDK

...向下滚动到部署并将部署目标设置为 7.0: Screenshot from Settings showing deployment target

请注意,通过更改此处的设置,您可以(几秒钟后)直接看到正在打开和关闭的警告

目标 = iOS 8.x Warnings on with target=8

目标 = iOS 7.x Warnings off with target=7

请忽略 SplashScreen 警告 ...

关于ios - 部署目标 iOS8 但希望支持 iOS7 - 弃用警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26939719/

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