我需要支持iOS 9和10来推送通知。我该怎么做呢?我在找一些主意。我用的是UserNotificationsUI.framework.但它在iOS 9坠毁。
发布于 2016-12-03 09:12:55
新的和旧的框架
如果您使用下面的命令来区分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='//.Copyright‘DIFFBIN=/usr/bin/diff $DIFFBIN -U 1 -r -x '.tbd’-x‘$OptIgnore $UIKit9Dir $UIKit10Dir|egrep -C 1“NS_CLASS_DEPRECATED_IOS。
这两种方法都是在工作时实现的
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;endif
} else {
UILocalNotification *localNotifacation = [self getLocalNotificationFromLaunchOptions:launchOptions];
if (localNotifacation) {
NSString *title = localNotifacation.alertBody;
[self addLabel:title];
}
}然后实现您需要的任何远程通知方法。
https://stackoverflow.com/questions/40946071
复制相似问题