title: Check if user allowed local notifications or not. iOS 8. Obj-C
body: <p>Is there no simple way of testing if the user has allowed local notifications? I noticed a warning in my console after I denied the sending of local notifications. When the relevant event occurred it said that the app tried to send a notifcation even though the user didn't allow it. I want to check if it's allowed before attempting to display a notification. See the comment in my condition, how do I do that?</p>
  
  <p>My code is:</p>
  
  <pre><code>app = [UIApplication sharedApplication];
  -(void)showBackgroundNotification:(NSString *) message {
  //check if app is in background and check if local notifications are allowed.
      if (app.applicationState == UIApplicationStateBackground /*&amp;&amp; LocalNotificationsAreAllowed*/){
          UILocalNotification *note = [[UILocalNotification alloc]init];
          note.alertBody = message;
          note.fireDate = [NSDate dateWithTimeIntervalSinceNow:0.0];
          [app scheduleLocalNotification :note];
      }
  }
  </code></pre>
  
  <p>I get prompt the user for permission like so:</p>
  
  <pre><code>UIUserNotificationSettings *settings;
  if ([app     respondsToSelector:@selector(registerUserNotificationSettings:)])
  {
      settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge|UIUserNotificationTypeAlert|UIUserNotification    TypeSound) categories:nil];
      [app registerUserNotificationSettings:settings];
  }
  </code></pre>
  
  <p>couldn't I use settings object?</p>
  
  <p>EDIT: I think I have solved it. This seems to work.</p>
  
  <pre><code>-(void)showBackgroundNotification:(NSString *) message {
      if (app.applicationState == UIApplicationStateBackground &amp;&amp; [app currentUserNotificationSettings].types != UIUserNotificationTypeNone){
          UILocalNotification *note = [[UILocalNotification alloc]init];
          note.alertBody = message;
          note.fireDate = [NSDate dateWithTimeIntervalSinceNow:0.0];
          [app scheduleLocalNotification :note];
      }
  }
  </code></pre>