Registering for local notifications

suggest change

In order to present local notifications to the user, you have to register your app with the device:

Swift

let settings = UIUserNotificationSettings(forTypes: [.Badge, .Sound, .Alert], categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)

Objective-C

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];

This will present an alert the first time it is called:

Regardless of what the user chooses, the alert will not show up again and changes will have to be initiated by the user in Settings.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents