iOS8 check permission of remotenotificationtype - ios

I can check if user granted notification (alert) permission or not before iOS8 like that:
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types & UIRemoteNotificationTypeAlert)
{
//user granted
}
it is not working on iOS8, it says:
iOS (3.0 and later) Deprecated:Register for user notification settings using the registerUserNotificationSettings: method instead.
console says:
enabledRemoteNotificationTypes is not supported in iOS 8.0 and later.
so how can I check it on iOS 8?

Ok I solved my problem like this:
BOOL isgranted = false;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if ([[UIApplication sharedApplication] respondsToSelector:#selector(isRegisteredForRemoteNotifications)])
{
isgranted = [[UIApplication sharedApplication] isRegisteredForRemoteNotifications];
}
#else
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types & UIRemoteNotificationTypeAlert)
{
isgranted = true;
}
#endif

I expanded on woheras answer a bit to be more dynamic
- (BOOL)pushNotificationsEnabled
{
BOOL isgranted = false;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0){
if ([[UIApplication sharedApplication] respondsToSelector:#selector(isRegisteredForRemoteNotifications)])
{
isgranted = [[UIApplication sharedApplication] isRegisteredForRemoteNotifications];
}else{
}
}else{
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types & UIRemoteNotificationTypeAlert)
{
isgranted = true;
}else{
}
}
return isgranted;
}

I didn't have much luck using isRegisteredForNotifications. I ended up using currentUserNotificationSettings instead.
+ (BOOL)notificationServicesEnabled {
BOOL isEnabled = NO;
if ([[UIApplication sharedApplication] respondsToSelector:#selector(currentUserNotificationSettings)]){
UIUserNotificationSettings *notificationSettings = [[UIApplication sharedApplication] currentUserNotificationSettings];
if (!notificationSettings || (notificationSettings.types == UIUserNotificationTypeNone)) {
isEnabled = NO;
} else {
isEnabled = YES;
}
} else {
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types & UIRemoteNotificationTypeAlert) {
isEnabled = YES;
} else{
isEnabled = NO;
}
}
return isEnabled;
}

Trying to shoot two birds with one stone here. First, instead of checking for isRegisteredForRemoteNotifications(), you should probably check for currentUserNotificationSettings(). With that, you can see if Alerts, Sound, etc are allowed. Secondly, it seems like the iOS version check is redundant here. Simply checking if object responds to selector is good enough. Lastly, the code example is in Swift, for that one user who asked for it :P
func hasPushNotificationsEnabled() -> Bool {
if UIApplication.sharedApplication().respondsToSelector("currentUserNotificationSettings") {
let settings = UIApplication.sharedApplication().currentUserNotificationSettings()
return (settings.types & UIUserNotificationType.Alert) != UIUserNotificationType.None
}
let types = UIApplication.sharedApplication().enabledRemoteNotificationTypes()
return (types & UIRemoteNotificationType.Alert) != UIRemoteNotificationType.None
}

Here is how to do Daniels answer in Swift 2.0
func hasPushEnabled() -> Bool {
//ios 8+
if UIApplication.sharedApplication().respondsToSelector("currentUserNotificationSettings") == true {
let settings = UIApplication.sharedApplication().currentUserNotificationSettings()
if (settings?.types.contains(.Alert) == true){
return true
} else {
return false
}
}
else {
let types = UIApplication.sharedApplication().enabledRemoteNotificationTypes()
if types.contains(.Alert) == true {
return true
} else {
return false
}
}
}

Related

How to implement interactive remote notifications in iOS Objective-c

I am new in Objective-c. I want to create a interactive remote notification which have two action, one is call 'OK' and another is called 'VIEW'. When user receive notification through APNS that time if user click 'OK' the notification have to be dismiss and if user click 'VIEW' that time open a particular page of my app. That's it.
I have go through many web documents and grab some concept of notification payload. But I am not able to implement this step wise. Can any one assist me, how can I implement this functionality. And please anyone don't mark as a duplicate question. Thanks
Note: I have use my own constants here for category like KNotificatoin_IDENTIFIER_CATEGORY_NEW_BID use your at that place
Register for push
- (void) registerPushNotification {
UIUserNotificationType type = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound;
UIUserNotificationSettings *setting = [UIUserNotificationSettings settingsForTypes:type categories:[NSSet setWithObjects:[self createActionNotificationsSettingForApproveBID],[self createActionNotificationsSettingForCancelingRequest ], nil]];
[[UIApplication sharedApplication] registerUserNotificationSettings:setting];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
- (UIMutableUserNotificationCategory *) createActionNotificationsSettingForApproveBID {
UIMutableUserNotificationAction *actionApproveBID = [[UIMutableUserNotificationAction alloc] init];
[actionApproveBID setIdentifier:KNotificatoin_IDENTIFER_ACTION_APPROVEBID];
actionApproveBID.activationMode = UIUserNotificationActivationModeForeground;
actionApproveBID.title = #"Approve";
actionApproveBID.authenticationRequired = true;
[actionApproveBID setDestructive: false];
UIMutableUserNotificationAction *actionCancelDialog = [[UIMutableUserNotificationAction alloc] init];
[actionCancelDialog setIdentifier:KNotificatoin_IDENTIFER_ACTION_DETAILS];
actionCancelDialog.activationMode = UIUserNotificationActivationModeForeground;
actionCancelDialog.title = #"Details";
actionCancelDialog.authenticationRequired = true;
[actionCancelDialog setDestructive: false];
UIMutableUserNotificationCategory *cateogoryApproveBID = [[UIMutableUserNotificationCategory alloc] init];
cateogoryApproveBID.identifier = KNotificatoin_IDENTIFIER_CATEGORY_NEW_BID;
[cateogoryApproveBID setActions:#[actionApproveBID,actionCancelDialog] forContext:UIUserNotificationActionContextDefault];
[cateogoryApproveBID setActions:#[actionApproveBID,actionCancelDialog] forContext:UIUserNotificationActionContextMinimal];
return cateogoryApproveBID;
}
- (UIMutableUserNotificationCategory *) createActionNotificationsSettingForCancelingRequest {
UIMutableUserNotificationAction *actionGetMoreBids = [[UIMutableUserNotificationAction alloc] init];
[actionGetMoreBids setIdentifier:KNotificatoin_IDENTIFER_ACTION_APPROVEBID];
actionGetMoreBids.activationMode = UIUserNotificationActivationModeForeground;
actionGetMoreBids.title = #"Get more bids";
actionGetMoreBids.authenticationRequired = true;
[actionGetMoreBids setDestructive: false];
UIMutableUserNotificationAction *actionEditRequest = [[UIMutableUserNotificationAction alloc] init];
[actionEditRequest setIdentifier:KNotificatoin_IDENTIFER_ACTION_EDIT_REQUEST];
actionEditRequest.activationMode = UIUserNotificationActivationModeForeground;
actionEditRequest.title = #"Edit request";
actionEditRequest.authenticationRequired = true;
[actionEditRequest setDestructive: false];
UIMutableUserNotificationCategory *categoryCancelRequest = [[UIMutableUserNotificationCategory alloc] init];
categoryCancelRequest.identifier = KNotificatoin_IDENTIFER_ACTION_MORE_BIDS;
[categoryCancelRequest setActions:#[actionGetMoreBids,actionEditRequest] forContext:UIUserNotificationActionContextDefault];
[categoryCancelRequest setActions:#[actionGetMoreBids,actionEditRequest] forContext:UIUserNotificationActionContextMinimal];
return categoryCancelRequest;
}
How you will handle actions ?
- (void) application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler {
NSLog(#" APPLICATION STATUS %ld",(long)[UIApplication sharedApplication].applicationState);
if ([[[userInfo objectForKey:#"aps"] objectForKey:kCategory] isEqualToString:KNotificatoin_IDENTIFIER_CATEGORY_NEW_BID]){
if ([identifier isEqualToString:KNotificatoin_IDENTIFER_ACTION_APPROVEBID]) {
NSMutableDictionary *dictData = [NSMutableDictionary dictionaryWithDictionary:userInfo];
[dictData setObject:#17 forKey:kType];
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive || self.isApplicationIsInActiveState) {
[self saveDictionaryForPushActiveState:dictData];
} else {
[self navigatateAsPerPush:dictData allowInActiveState:NO];
}
}
else if ([identifier isEqualToString:KNotificatoin_IDENTIFER_ACTION_DETAILS]) {
NSLog(#"You chose action 2.");
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive || self.isApplicationIsInActiveState) {
[self saveDictionaryForPushActiveState:userInfo];
} else {
[self navigatateAsPerPush:userInfo allowInActiveState:NO];
}
}
} else if ([[[userInfo objectForKey:#"aps"] objectForKey:kCategory] isEqualToString:KNotificatoin_IDENTIFIER_NOTIFICATION_REQUEST]){
NSMutableDictionary *dictData = [NSMutableDictionary dictionaryWithDictionary:userInfo];
if ([identifier isEqualToString:KNotificatoin_IDENTIFER_ACTION_EDIT_REQUEST]) {
NSLog(#"You chose action 1.");
[dictData setObject:#16 forKey:kType];
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive || self.isApplicationIsInActiveState) {
[self saveDictionaryForPushActiveState:dictData];
} else {
[self navigatateAsPerPush:dictData allowInActiveState:NO];
}
}
else if ([identifier isEqualToString:KNotificatoin_IDENTIFER_ACTION_MORE_BIDS]) {
NSLog(#"You chose action 2.");
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive || self.isApplicationIsInActiveState) {
[self saveDictionaryForPushActiveState:dictData];
} else {
[self navigatateAsPerPush:dictData allowInActiveState:NO];
}
}
}
if (completionHandler) {
completionHandler();
}
}
Hope it is helpful to you
With the iOS 12 SDK, your app take advantage of Interactive Controls in Notifications
Notification content app extensions now support user interactivity in custom views. If the content of your app’s notifications needs to prompt user interaction, add controls like buttons and switches.
To enable user interactions:
Open your Notification Content Extension’s info.plist file.
Add the UNNotificationExtensionUserInteractionEnabled key to your extension attributes. Give it a Boolean value, set to YES.
Here is reference like to know more
https://developer.apple.com/documentation/usernotificationsui/customizing_the_appearance_of_notifications
https://developer.apple.com/documentation/usernotificationsui/customizing_the_appearance_of_notifications
https://developer.apple.com/documentation/usernotificationsui

iOS 10 / 9 Push Notifications

I need to update an application from us to support iOS 9 and iOS 10, so my problem is to use UNUserNotificationCenter for PushNotifications.
So with iOS 9 we have a method which returns result of UIUserNotificationSettings like
- (BOOL)alertEnabled {
UIUserNotificationSettings *theSettings = [[UIApplication sharedApplication] currentUserNotificationSettings];
return [theSettings types] & UIUserNotificationTypeAlert;
}
With iOS 10 I did something like
- (void)userNotificationsAuthorization :(void (^)(BOOL alertIsActive))completion {
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
completion(settings.alertSetting == UNNotificationSettingEnabled);
}];
}
Call it and get it via completion handler.
My Question: Is there some possibility to use getNotificationSettingsWithCompletionHandler and return the value instead of the completion handler that I can use it into my alertEnabled method?
Thanks a lot.
Update:
With this approach it's working
- (BOOL)alertIsEnabled {
__block BOOL alertIsActive = NO;
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"10.0")) {
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
alertIsActive = settings.alertSetting == UNNotificationSettingEnabled;
dispatch_semaphore_signal(sem);
}];
dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
}
else {
UIUserNotificationSettings *theSettings = [[UIApplication sharedApplication] currentUserNotificationSettings];
alertIsActive = [theSettings types] & UIUserNotificationTypeAlert;
}
return alertIsActive;
}
but maybe there is a better solution
So, after a week of tests, it's working fine for me.
For my specific problem, I created a custom class.
SpecicPush.h
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger , PushNotificationType) {
PushNotificationTypeNone = 0, // the application may not present any UI upon a notification being received
PushNotificationTypeBadge = 1 << 0, // the application may badge its icon upon a notification being received
PushNotificationTypeSound = 1 << 1, // the application may play a sound upon a notification being received
PushNotificationTypeAlert = 1 << 2, // the application may display an alert upon a notification being received
};
#interface SpecificPush : NSObject
#property (nonatomic, readonly) PushNotificationType currentNotificationSettings;
+ (SpecificPush *)sharedInstance;
- (PushNotificationType)types;
#end
SpecificPush.m
#import "SpecificPush.h"
#import <UserNotifications/UserNotifications.h>
#interface SpecificPush()
#property (nonatomic) PushNotificationType currentNotificationSettings;
#end
#implementation SpecificPush
#pragma mark - Init
static SpecificPush *instance = nil;
+ (SpecificPush *)sharedInstance
{
#synchronized (self)
{
if (instance == nil)
{
[SpecificPush new];
}
}
return instance;
}
- (instancetype)init
{
NSAssert(!instance, #"WARNING - Instance of SpecifishPush already exists");
self = [super init];
if (self)
{
self.currentNotificationSettings = PushNotificationTypeNone;
}
instance = self;
return self;
}
- (PushNotificationType)types
{
if (IS_IOS10)
{
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings *settings) {
if ((settings.soundSetting == UNNotificationSettingDisabled) && (settings.alertSetting == UNNotificationSettingDisabled) && (settings.soundSetting == UNNotificationSettingDisabled))
{
self.currentNotificationSettings = PushNotificationTypeNone;
}
if (settings.badgeSetting == UNNotificationSettingEnabled)
{
self.currentNotificationSettings = PushNotificationTypeBadge;
}
if (settings.soundSetting == UNNotificationSettingEnabled)
{
self.currentNotificationSettings = PushNotificationTypeSound;
}
if (settings.alertStyle == UNNotificationSettingEnabled)
{
self.currentNotificationSettings = PushNotificationTypeAlert;
}
dispatch_semaphore_signal(semaphore);
}];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_release(semaphore);
}
else
{
UIUserNotificationSettings *settings = [[UIApplication sharedApplication] currentUserNotificationSettings];
if (settings.types == UIUserNotificationTypeNone)
{
self.currentNotificationSettings = PushNotificationTypeNone;
}
if (settings.types & UIUserNotificationTypeBadge)
{
self.currentNotificationSettings = PushNotificationTypeBadge;
}
if (settings.types & UIUserNotificationTypeSound)
{
self.currentNotificationSettings = PushNotificationTypeSound;
}
if (settings.types & UIUserNotificationTypeAlert)
{
self.currentNotificationSettings = PushNotificationTypeAlert;
}
}
return self.currentNotificationSettings;
}
#end
I used the same NS_ENUM as UIUserNotificationType. Now I can easy use old implementation. Insted of
- (BOOL)alertEnabled {
UIUserNotificationSettings *theSettings = [[UIApplication sharedApplication] currentUserNotificationSettings];
return [theSettings types] & UIUserNotificationTypeAlert;
}
I use
- (BOOL)alertEnabled {
return [[SpecificPush sharedInstance] types] & PushNotificationTypeAlert;
}

call of [[UIApplication sharedApplication] currentUserNotificationSettings].types returns always UIUserNotificationTypeNone

I need to check if user have enabled push notifications in Settings. For this I use this code:
if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications] == NO) {
NSLog(#"NO");
// NO
}
if ([[UIApplication sharedApplication]respondsToSelector:#selector(currentUserNotificationSettings)]){
UIUserNotificationSettings *noticationSettings = [[UIApplication sharedApplication] currentUserNotificationSettings];
if (!noticationSettings || (noticationSettings.types == UIUserNotificationTypeNone)) {
NSLog(#"NO");
// here it does not work, I enabled push notifications
// in settings and noticationSettings.types returns UIUserNotificationTypeNone
// NO
} else {
NSLog(#"YES");
// YES
}
}
but problem is that noticationSettings.types returns alwyas UIUserNotificationTypeNone, regardless whether are push notifications enabled in Settings or not.
As you can see on the picture, I have enabled push notifications, but noticationSettings.types returns me UIUserNotificationTypeNone, can anybody tell me where could be the problem? Thanks
Your screenshot indicates that you did not call registerUserNotificationSettings with UIUserNotificationTypeBadge or UIUserNotificationTypeSound or UIUserNotificationTypeAlert.
Try the following:
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge
|UIUserNotificationTypeSound
|UIUserNotificationTypeAlert) categories:nil];
UIApplication *application = [UIApplication sharedApplication];
[application registerUserNotificationSettings:settings];

Alert user to enable notifications from settings in ios

Hi in my app i have notification section and user can enable notifications using switch.After first launch when ever user on the switch i am getting don't allow or ok alertview from ios.If user select don't allow and switch will be off and user will not get notifications. Now if user try to on the switch i want to show an alert to user with text "Please enable notifications from settings".Can any one please suggest the way to do this.
For UILocalNotification permission check the following, types parameter value will be none incase user has not allowed it.
[[UIApplication sharedApplication] currentUserNotificationSettings]
You can check the the permission using isRegisteredForRemoteNotifications method.
- (void)checkForNotificationPermission
{
if (!([[UIApplication sharedApplication] isRegisteredForRemoteNotifications] && [self pushNotificationsEnabled]))
{
// Show alert here
}
}
// For fixing iOS 8 issue mentioned here http://stackoverflow.com/a/28441181/1104384
- (BOOL)pushNotificationsEnabled
{
if ([[UIApplication sharedApplication] respondsToSelector:#selector(currentUserNotificationSettings)])
{
UIUserNotificationType types = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];
return (types & UIUserNotificationTypeAlert);
}
else
{
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
return (types & UIRemoteNotificationTypeAlert);
}
}
NSString *iOSversion = [[UIDevice currentDevice] systemVersion];
NSString *prefix = [[iOSversion componentsSeparatedByString:#"."] firstObject];
float versionVal = [prefix floatValue];
if (versionVal >= 8)
{
if ([[UIApplication sharedApplication] currentUserNotificationSettings].types != UIUserNotificationTypeNone)
{
NSLog(#" Push Notification ON");
}
else
{
NSString *msg = #"Please press ON to enable Push Notification";
UIAlertView *alert_push = [[UIAlertView alloc] initWithTitle:#"Push Notification Service Disable" message:msg delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"Setting", nil];
alert_push.tag = 2;
[alert_push show];
NSLog(#" Push Notification OFF");
}
}
else
{
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types != UIRemoteNotificationTypeNone)
{
NSLog(#" Push Notification ON");
}
else
{
NSString *msg = #"Please press ON to enable Push Notification";
UIAlertView *alert_push = [[UIAlertView alloc] initWithTitle:#"Push Notification Service Disable" message:msg delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"Setting", nil];
alert_push.tag = 2;
[alert_push show];
NSLog(#" Push Notification OFF");
}
}
UIUserNotificationType allNotificationTypes =
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
UIUserNotificationSettings *settings =
[UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
[[UIAp
plication sharedApplication] registerUserNotificationSettings:settings];
// [[UIApplicationsharedApplication]registerForRemoteNotifications];
if ([[UIApplication sharedApplication] respondsToSelector:#selector(currentUserNotificationSettings)]) {
UIUserNotificationType types = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];
if (types == UIUserNotificationTypeNone) {
[_TransparentView setBackgroundColor:[[UIColor clearColor] colorWithAlphaComponent:0.8]];
lblDescription.text=#"Please enable notifications from settings.";
}
}
}
Try this code. It will work for iOS 8.0 later and before versions.
if (([[[UIDevice currentDevice] systemVersion] compare:8.0 options:NSNumericSearch] != NSOrderedAscending)) {
if (![[UIApplication sharedApplication] isRegisteredForRemoteNotifications])
{
DisplayAlert(#"Please enable Permission from Settings->App Name->Notifications->Allow Notifications");
return;
}
}
else{
UIRemoteNotificationType status = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (status == UIRemoteNotificationTypeNone)
{
DisplayAlert(#"Please enable Permission from Settings->App Name->Notifications->Allow Notifications");
return;
}
}

Need assistance regarding UILocalNotification permissions

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if ([UIApplication instancesRespondToSelector:#selector(registerUserNotificationSettings:)]){
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
}
This code is for registering for UILocalNotification and this will also popup this:
Question 1: At this state when user has not chosen any option, How do I get notified when user choose one of the option which is Don't Allow or Ok? So I can execute app accordingly.
--
UIUserNotificationSettings *current = [[UIApplication sharedApplication] currentUserNotificationSettings];
UIUserNotificationType required = UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
if(current.types & required) {
NSLog(#"Permission present: %lu", (unsigned long)current.types);
} else {
NSLog(#"Permission not present: %lu", (unsigned long)current.types);
}
When app will launch after first time, with this code I am trying to fetch which permission user has allowed (maybe he goto settings and disabled all types of notification alerts).
Question 2: I am simply getting numbers in log like 7 for the types of permission I am checking and 0 if user has not allowed the UILocalNotification. How to check for permissions correctly?
I used the below method in one of my project to determine whether the user has given permission or not, or whether he/she actually turned off the notifications in settings. Put this method in Appdelegate and check
-(BOOL)notificationServicesEnabled {
BOOL isEnabled = NO;
if ([[UIApplication sharedApplication] respondsToSelector:#selector(currentUserNotificationSettings)]){
UIUserNotificationSettings *notificationSettings = [[UIApplication sharedApplication] currentUserNotificationSettings];
if (!notificationSettings || (notificationSettings.types == UIUserNotificationTypeNone)) {
isEnabled = NO;
} else {
isEnabled = YES;
}
} else {
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types & UIRemoteNotificationTypeAlert) {
isEnabled = YES;
} else{
isEnabled = NO;
}
}
return isEnabled;
}
Then you can simple check with condition
if([self notificationServicesEnabled])

Resources