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:
-(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]; } }
Then i use the following code for going to the "Settings tab >> Notification center", so that user can on it manually :
- (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)]; } } }
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".
If you allow notifications on your iPhone from every app you use, you may spend more time checking your notifications than getting things done. While some notifications can be very important – phone calls and text messages, for example – too many notifications is bad for our sanity.
Nothing will interrupt you, but all the notifications will still appear when you pull down the windowshade. On Android, you can choose "Show Silently," a similar setup. It's not like turning off notifications shuts you out from using the apps you like.
Find your notifications in Notification CenterOn the Lock Screen: Swipe up from the middle of the screen. On other screens: Swipe down from the top center. Then you can scroll up to see older notifications, if there are any.
Well, science is here to save the day (as always) with one simple answer: disable all notifications. A study from Carnegie Mellon University and Telefonica suggests that using your smartphone sans notifications for a mere 24-hour period can noticeably improve your concentration, as well as reduce your stress levels.
In iOS 8 you can now use:
[[UIApplication sharedApplication] isRegisteredForRemoteNotifications];
And to check how the settings are setup you could use:
[[UIApplication sharedApplication] currentUserNotificationSettings];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With