![](/img/trans.png)
[英]How can I support both iOS 4.X SDK and iOS 5 SDK in my iPhone app?
[英]Swift onesignal can I allow my app to support both ios 9 and ios 10 notifications
我想知道我是否可以允許我的應用程序同時支持ios 9和ios 10通知?
我只是將一個通知服務整合到我的應用程序中,並查看支持視頻/ GIF等的ios10部分。
因此,如果我想允許通知進入我的應用程序,我可以只支持ios9,或者我也可以支持ios 10,我的意思是如果設備運行時通知會回退到ios 9樣式。
現在我有這個:
OneSignal.initWithLaunchOptions(launchOptions, appId: "myId", handleNotificationReceived: { (notification) in
print("Received Notification - \(notification?.payload.notificationID)")
}, handleNotificationAction: { (result) in
// This block gets called when the user reacts to a notification received
let payload = result?.notification.payload
var fullMessage = payload?.title
//Try to fetch the action selected
if let additionalData = payload?.additionalData, let actionSelected = additionalData["actionSelected"] as? String {
fullMessage = fullMessage! + "\nPressed ButtonId:\(actionSelected)"
}
print(fullMessage)
}, settings: [kOSSettingsKeyAutoPrompt : true, kOSSettingsKeyInFocusDisplayOption : OSNotificationDisplayType.notification.rawValue])
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().getNotificationCategories { (categories) in
let myAction = UNNotificationAction(identifier: "actionSelected", title: "Hit Me!", options: .foreground)
let myCategory = UNNotificationCategory(identifier: "myOSContentCategory", actions: [myAction], intentIdentifiers: [], options: .customDismissAction)
let mySet = NSSet(array: [myCategory]).addingObjects(from: categories) as! Set<UNNotificationCategory>
UNUserNotificationCenter.current().setNotificationCategories(mySet)
}
}
如果您在OneSignal的儀表板或REST API上設置iOS 10媒體附件,它仍將被發送到沒有附件的iOS 9和舊設備。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.