ios - objective-c 中 ios 9 的 UserNotificationsUI.framework 错误

标签 ios objective-c apple-push-notifications

<分区>


关闭 6 年前

我需要同时支持 iOS 9 和 10 的推送通知。我该怎么做 ?我正在寻找一些想法。我使用了 UserNotificationsUI.framework。但它在 iOS 9 中崩溃。

最佳答案

既是新旧框架

如果您使用以下命令区分 SDK“iOS 10.0”(Xcode 8) 和 SDK“iOS 9.0”,您会发现 SDK“iOS 10.0”(Xcode 8) 中弃用了六个与通知相关的 UIKit 类。

UIKit9Dir="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/UIKit.framework" UIKit10Dir="/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/UIKit.framework"

OptIgnore=--ignore-matching-lines='//.版权所有' DIFFBIN=/usr/bin/差异 $DIFFBIN -U 1 -r -x '.tbd' -x '.modulemap' $OptIgnore $UIKit9Dir $UIKit10Dir|egrep -C 1 "NS_CLASS_DEPRECATED_IOS."|grep 接口(interface)

在工作的同时实现了这两种方法

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0")) {

如果 XCODE_VERSION_GREATER_THAN_OR_EQUAL_TO_8

    /// schedule localNotification, the delegate must be set before the application returns from applicationDidFinishLaunching:.
    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    center.delegate = self;

结束

} else {
    UILocalNotification *localNotifacation = [self getLocalNotificationFromLaunchOptions:launchOptions];
    if (localNotifacation) {
        NSString *title = localNotifacation.alertBody;
        [self addLabel:title];
    }
}

然后实现您需要的任何远程通知方法。

关于ios - objective-c 中 ios 9 的 UserNotificationsUI.framework 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40946071/

上一篇:android - 如何在混合应用程序中安全地创建登录系统(phonegap/cordova)

下一篇:ios - OpenGL ES : Should I use DrawElements for a TRIANGLE_STRIP array?

相关文章:

ios - 是否可以以编程方式修改 ATS 设置

swift - 在数据库中存储 token 的 Http post 请求

ios - 没有关系的核心数据中的两个实体是糟糕的设计吗?

ios - Swift - pathForResource inDirectory 参数

objective-c - 什么时候应该将 header 导入 Prefix.pch?

iphone - 如何从 .clp(CLIPS) 文件中获取响应?

objective-c - 从 NSTokenField 获取 token

ios - Xcode 机器人服务器持续集成卡在 "Getting sources..."

ios - 推送通知的自定义声音不起作用

php - 使用 PEM 文件在 PHP 中推送通知