I am implementing new notifications, with UNUserNotificationCenter. But I need to keep it backwards compatible, therefore I have checks all over the place:
if #available(iOS 10.0, *) { ... }
else { ... }
Which seems to work fine in iOS10. To be able to use the UNUserNotificationCenter framework, I have to import:
import NotificationCenter
But it crashes the iOS9.3, because it does not know what it is. It is a compile time action, not a runtime action - so it means I can not put condition on the imports.If I create a separate class, and put
@available(iOS 10.0, *)
class ....
there the imports are also happening before the class implementation. How should I work around this issue?
Try navigating to Build Phases->Link Binary with Libraries and add NotificationCenter and set the status to "optional" rather than "required".
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