RPM
RPM

Reputation: 3436

Do Local Notifications need user permission on iOS?

I am using UILocalNotification in my app to schedule notifications. The notifications work fine and show up when I want them to. I dont have an issue with that. I am NOT doing any remote/push notifications.

What got me wondering is that I never saw the famous permissions dialog that you usually see for push notifications in several app. I even reset my device and ran my app. That still didn't cause the permission dialog to show up.

Does this permission dialog not show up if your app is using only local notifications or am I not implementing some method that actually causes the app to ask for this permission?

I know I could implement my own dialog after the app started that asked the user for this permission but I was hoping that Apple took care of that, especially since it treats remote and local notifications the same in the Settings app.

Upvotes: 28

Views: 17620

Answers (5)

luvieere
luvieere

Reputation: 37534

Yes, in iOS8, local notifications do require permissions.

The documentation for registerUserNotificationSettings: stipulates that

If your app displays alerts, play sounds, or badges its icon while in the background, you must call this method during your launch cycle to request permission to alert the user in those ways. Typically, you make this request if your app uses local or push notifications to alert the user to new information involving your app.

It is recommended that you call this method before you schedule any local notifications or register with the push notification service.

Upvotes: 21

Kris Subramanian
Kris Subramanian

Reputation: 1900

Apple's documentation for presentLocalNotificationNow and scheduleLocalNotification says,

Prior to scheduling any local notifications, you must call the registerUserNotificationSettings: method to let the system know what types of alerts, if any, you plan to display to the user.

So I am not sure how others in this page are saying Local Notifications do not need User Permissions.

Checkout this other discussion on the same topic:

Ask for User Permission to Receive UILocalNotifications in iOS 8

Upvotes: 4

Ted
Ted

Reputation: 23756

NOTE: this includes push notifications / remote notifications

when using Xcode6 with iOS7 or iOS8 Test when registerUserNotificationSettings: API is available at runtime.

if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {  
    UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];  
    [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];  
    [[UIApplication sharedApplication] registerForRemoteNotifications];  
} else {  
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];  
}  

Thanks to http://corinnekrych.blogspot.ae/2014/07/how-to-support-push-notification-for.html

Upvotes: 6

rishabh
rishabh

Reputation: 1165

Yes, that's correct. Local notifications do not need any OS permissions. However, as a good practice, I'd suggest giving an opt-out option for the user in such cases from your application. This would work well in two ways:

  1. An annoyed user, getting frustrated because of seeing local notification yet time & again, not knowing the difference between Push/Local notification might leave a bad review on the app store.
  2. Its always a good practice to provide flags to turn ON/OFF such functionality for a given user.

Upvotes: 2

RPM
RPM

Reputation: 3436

It looks like local notifications do not need any user permission. The Permission dialog just shows up for the Push Notifications. I am able to schedule/cancel local notifications without any user permission.

Upvotes: 12

Related Questions