When trying to register for push notifications under iOS 8.x:
application.registerForRemoteNotificationTypes(UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound)
I get the following error:
registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.
Any ideas what is the new way of doing it? It does work when I run this Swift app on iOS 7.x.
EDIT
On iOS 7.x when I include the conditional code I get (either SystemVersion conditional or #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000)
dyld: Symbol not found: _OBJC_CLASS_$_UIUserNotificationSettings
If you like to add support to IOS7 IOS8 you can apply this code into your project .
I think this is the better way to keep backwards compatibility if we go with this approach, it is working for my case and hope will work for you. Also pretty easy to understand.
After Xcode 6.1 Beta the code below works, slight edit on Tom S code that stopped working with the 6.1 beta (worked with previous beta):
For the Swift-inclined:
Swift 2.0
iOS 8 has changed notification registration in a non-backwards compatible way. While you need to support iOS 7 and 8 (and while apps built with the 8 SDK aren't accepted), you can check for the selectors you need and conditionally call them correctly for the running version.
Here's a category on UIApplication that will hide this logic behind a clean interface for you that will work in both Xcode 5 and Xcode 6.
Header:
Implementation: