I have an application that uses local notifications and supports iOS 10. I'm trying to add support for iOS 9, which requires me to use the old location notification API. I am trying to use @available and #available in my iOS 10 code, and I cannot figure out how to get my central variable for iOS 10 devices only.
When I set my goal from iOS 10 to 9, I get an error for this variable: "UNUserNotificationCenter is only available on iOS 10.0 or later." He suggests adding “@available (iOS 10.0, *)” to the whole class that I don’t want to do, as this class has code that will be used for iOS 9. I appreciate any suggestions on how to limit my center for iOS 10.
class ViewController: UIViewController, UITextFieldDelegate {
let center = UNUserNotificationCenter.current()
...
source
share