Understand how to best take advantage of the revamped iOS8 push notifications functionality in your mobile app.
Ported Post: This entry was originally published in the Artisan Mobile blog. Artisan was rebranded as In-App Marketing after being acquired by TUNE in July of 2015.
Apple’s new version of iOS8 includes more than 4,000 new APIs that enable developers to add some really exciting new features and capabilities to their applications. But one of the existing APIs that got a nice facelift relates to push notifications. iOS8 is now going to allow developers to make notifications more interactive by allowing for buttons and text input as compared to the traditional static text. An example would be allowing users to reply to a text right from the lock screen or without navigating out of another app.
iOS8 push notifications are pretty cool, but there is a catch for developers.
Apple requires every iOS8 app to change the way they register for push notifications and to check if the user has successfully enabled them. In iOS8 developers are going to have to use the following new methods and types to enable push in their apps:
[[UIApplication sharedApplication] registerUserNotificationSettings [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
This is fairly straightforward for iOS8, but what about iOS7 and before? Here’s the wrinkle. You still need to use the old method to register for notifications if your app is not running iOS8. The simple solution is check the version of iOS that the app is running in and use the correct notification registration. Here’s what that would look like:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
The team at Artisan is really psyched to see how developers will utilize the new features and capabilities of iOS8! We’ve already starting to bake them into our platform so stay tuned for some exciting updates.
Technical Note: The Artisan SDK has full iOS8 support but you’ll need to do the updates to your code described above, download the latest Artisan SDK and compile it into your app.
Feel free to reach out to us with any questions around iOS8 push notifications.
Author
Becky is the Senior Content Marketing Manager at TUNE. Before TUNE, she handled content strategy and marketing communications at several tech startups in the Bay Area. Becky received her bachelor's degree in English from Wake Forest University. After a decade in San Francisco and Seattle, she has returned home to Charleston, SC, where you can find her strolling through Hampton Park with her pup and enjoying the simple things between adventures with friends and family.
Leave a Reply
You must be logged in to post a comment.