Is this beacuse of deprecation of UILocalNotification API in iOS 10 …
That’s very unlikely. UILocalNotification has been deprecated but it still works. I tried this here in my office with a small test app. Here’s the code I used to post the notification:
let t = UIApplication.shared.beginBackgroundTask(expirationHandler: nil)
NSLog("schedule")
Timer.scheduledTimer(withTimeInterval: 5.0, repeats: false) { _ in
NSLog("fire")
let note = UILocalNotification()
note.alertBody = "Hello Cruel World!"
UIApplication.shared.presentLocalNotificationNow(note)
UIApplication.shared.endBackgroundTask(t)
}
And don’t forget you have to register for permission to post notifications:
let settings = UIUserNotificationSettings(types: [.alert], categories: nil)
UIApplication.shared.registerUserNotificationSettings(settings)
After setting the deployment target to iOS 10 I get lots of deprecation warnings when building the app, but the app functions just fine (built with Xcode 8.2, running on iOS 10.1.1).
IMPORTANT The code above was part of a quick hack; it is not intended to be production quality.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"