Issue
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.
Solution
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.
Answered By - matt Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.