For example in iOS 10 there's UserNotifications framework. Prior to that you just have to use:
let settings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
(I ran the code above on iOS 10 and nothing happened).
My generic question is: would running deprecated syntax crash all the time, just do nothing (as now) or how it treats is unknown?
I'm asking to get a better debugging understanding.
how it treats is unknown
Basically, that's right. It wouldn't crash, probably, but it isn't guaranteed to work either.
In the case of the UILocalNotification world, experience shows that if you link against iOS 10 your code won't work properly. You must switch over to the new UNUserNotificationCenter code.
But this is determined not by rule but by experimentation.
The one reliable general rule is that if something is deprecated for the current iOS version, don't use it. That is precisely what deprecation means.
Of course, if you want your code to link against iOS 10 but to run on both iOS 10 and iOS 9, say, you might have to include two completely different sets of code, taking advantage of Swift's if #available() syntax to respond to what system we're actually running under. In this particular case, you would have to do that in order to manage local notifications. But that is the price of progress. Apple (deliberately?) makes it hard for you to write backwards-compatible code.
Deprecated means Apple may remove it anytime in the future. It may work for a few more years but one day it will crash and you can't say you have not been warned. If you are writing new code, why start with something that's already obsolete? If this is in your existing code, consider updating it to the new API when have a chance.
A deprecation warning is exactly the tool that gave you time to do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With