iOS 8 brings some new features and changes, and among interesting changes are the new possibilities of app push notifications. In iOS 8, notifications will be a lot more interactive and will allow the user to engage with them to do certain actions without leaving the app which he or she is currently using, this gives us developers interesting range of possibilities to interact with our users through push or local notifications, for example to allow the user to post on Facebook or Twitter through the notification center, or to write back to a friend through a messaging app without even opening it. Of course with the new possibilities come the API changes, and one of them is the registering process to the APNS (Apple Push Notification Service). Although the changes are not big, they may leave a place to wonder what exactly needs to be changed in the code, in order to make it work with the API changes.
Before iOS 8, the app registration to the APNS and to push notifications was done through the method registerForRemoteNotificationTypes:(UIRemoteNotificationType), with UIRemoteNotificationTypeBadge, UIRemoteNotificationTypeAlert and UIRemoteNotificationTypeSound usually as parameters, this would tell our app that we would like to register to the APNS and to enable push notifications. The app would then ask the user if he or she would like the app to send them push notifications, on approval the method didRegisterForRemoteNotificationsWithDeviceToken would be called and from there we continued on to registering the device to our server through the device token.
In iOS 8, the method
is no longer supported, for those of you fellow developers who already tried, I’m sure you noticed the log message you get once you use the method to register the app to push notifications. The second part of the registration to the APNS in iOS 8 stays the same, once the user approves the usage of push notifications in the App, the method didRegisterForRemoteNotificationsWithDeviceToken will be called and from there you continue as usual.
weiterlesenChanges in iOS 8 Push Notifications