29th September 2014

Notifications in iOS 8

Guides | Tutorial By 2 years ago

In iOS 8 the notification behavour has changed.

Previously an app could send a user a local notification without their initial permission, but would need to get their permission if the user was to get notifications sent remotely as a push notification.

As of iOS 8 all notifications need to get user permission. Whether it’s local or push, your app now needs to present that user alert when wanting to deal with notifications.

Here’s what the OLD code would have looked like, note this was only if you wanted to do remote notifications

UIApplication* application = [UIApplication sharedApplication];
[application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

Here’s what apps now need to do:

UIApplication* application = [UIApplication sharedApplication];

if([application respondsToSelector:@selector(registerUserNotificationSettings:)])
	[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge  | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil]];
	[application registerForRemoteNotifications];

The best thing to come out of this is now you can get that “wants to send you notifications” alert on the simulator, making it much easier to test different notification scenarios 🙂

Recommended Posts

Interactive Notifications in iOS 8

Post by 2 years ago

In iOS 8 developers can now present interactive notifications in their apps. To do so, first you need to register all possible notification “categories”. A category is defined by a set of actions. In my

Got an idea?

We help entrepreneurs, organizations and established brands from around
the country bring ideas to life. We would love to hear from you!