Check if Push notifications Enabled or Location Services Enabled:
Push Notifications:
From iOS above 8.0 it registers the device and provides a Token even if the user opts out from pushes.
but, pushes are not presented to the user when the push is sent, so it will return true
.
- (BOOL)isPushNotificationsEnabled {
if ([[UIApplication sharedApplication] respondsToSelector:@selector(currentUserNotificationSettings)]) {
UIUserNotificationType types = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];
return (types & UIUserNotificationTypeAlert);
}
else {
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
return (types & UIRemoteNotificationTypeAlert);
}
}
enabledRemoteNotificationTypes
is deprecated since iOS8.
To check remote notifications status in iOS8 you can use:
[[UIApplication sharedApplication] isRegisteredForRemoteNotifications];
Check the answers here: detect “Allow Notifications” is on/off for iOS8
Read docs here:
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html#//apple_ref/occ/instm/UIApplication/currentUserNotificationSettings
Also read the thread here: https://forums.developer.apple.com/thread/16958
Location Services:
Needs to check for both locationServicesEnabled
and authorizationStatus
like,
if([CLLocationManager locationServicesEnabled] &&
[CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied)
{
//Enabled
}