gpt4 book ai didi

ios - Swift onesignal 我可以让我的应用程序同时支持 ios 9 和 ios 10 通知吗

转载 作者:行者123 更新时间:2023-11-28 08:24:20 26 4
gpt4 key购买 nike

我想知道我是否可以让我的应用同时支持 ios 9 和 ios 10 通知?

我刚刚将 onesignal 通知服务集成到我的应用程序中,并查看了支持视频/gif 等的 ios10 部分。

因此,如果我想允许通知进入我的应用程序,我可以只支持 ios9 还是我也可以支持 ios 10,我的意思是如果设备运行 ios 9 样式,通知会退回到 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 和更早版本的设备。

关于ios - Swift onesignal 我可以让我的应用程序同时支持 ios 9 和 ios 10 通知吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40499250/

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