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 all you need is the ios 8 code, this should do it.
This is cleaner way I am doing and it just works great
As you described, you will need to use a different method based on different versions of iOS. If your team is using both Xcode 5 (which doesn't know about any iOS 8 selectors) and Xcode 6, then you will need to use conditional compiling as follows:
If you are only using Xcode 6, you can stick with just this:
The reason is here is that the way you get notification permissions has changed in iOS 8. A
UserNotification
is a message shown to the user, whether from remote or from local. You need to get permission to show one. This is described in the WWDC 2014 video "What's New in iOS Notifications"