我想知道我是否可以允许我的应用支持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)
}
}
答案 0 :(得分:0)
如果您在OneSignal的信息中心或REST API上设置了iOS 10媒体附件,它仍将被发送到没有附件的iOS 9和旧设备。