title: Push Notification ON or OFF Checking in iOS
body: <p>I want to check "Push Notification option" in iOS device, any time if the application is running (or ON from resume mode). I use the following code to check, if the option is OFF:</p>
  
  <pre><code>-(void)PushNotificationServiceChecking
  {
      UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
  
      if (types == UIRemoteNotificationTypeNone)
      {
          NSString *msg = @"Please press ON to enable Push Notification";
          UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Push Notification Service Disable" message:msg delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"ON", nil];
          alert.tag = 2;
          [alert show];
      }
  }
  </code></pre>
  
  <p>Then i use the following code for going to the "Settings tab >> Notification center", so that user can on it manually :</p>
  
  <pre><code>- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  {
      if (alertView.tag == 2)
      {
          if (buttonIndex == 0)
          {
              // this is the cancel button
          }
          else if (buttonIndex == 1)
          {
              [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeAlert)];
          }
      }
  
  }
  </code></pre>
  
  <p>But, now the problem that I am facing is, it only appears at the 1st time after launching the application. It works as I want. But after that, if I turn OFF the "Push Notification option" from "settings" it gives me no "Alert Message".</p>