Alert user to enable notifications from settings in ios - 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;
}
}

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

didReceiveRemoteNotification not working ios9

I follow these steps for push notifications but un able to receive push on my device.
Steps
making and adding push app id and provisioning profile in my project
enable push notifications in my project
making p12 file nd .pem file
sending .pem file to php developer
use following code in my app delegate.m
The code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//ios 9
UIUserNotificationType types = UIUserNotificationTypeBadge |
UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *mySettings =
[UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];
return YES;
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
if (notificationSettings.types != UIUserNotificationTypeNone) {
NSLog(#"didRegisterUser");
[application registerForRemoteNotifications];
}
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken
{
NSString *token = [[devToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:#"<>"]];
token = [token stringByReplacingOccurrencesOfString:#" " withString:#""];
Globals *globlClass = [Globals sharedInstance];
globlClass.DeviceToken = [NSString stringWithFormat:#"%#",token];
NSLog(#"\n\n\n\n\n device token===%#\n\n\n\n",globlClass.DeviceToken);
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSLog(#"failed to regiser %#", err);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSLog(#"notification options %#", userInfo);
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Super" message:#"welcome" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
for (id key in userInfo) {
NSLog(#"key: %#, value: %#", key, [userInfo objectForKey:key]);
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:#"Your title here!" message:#"this gets covered" delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"OK", nil];
UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[myTextField setBackgroundColor:[UIColor whiteColor]];
myTextField.text = [userInfo objectForKey:key];
[myAlertView addSubview:myTextField];
[myAlertView show];
}
}
You need to register for remote notifications by call this method [[UIApplication sharedApplication] registerForRemoteNotifications] after registering user notification settings.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//ios 9
UIUserNotificationType types = UIUserNotificationTypeBadge |
UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *mySettings =
[UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];
//call this method here
[[UIApplication sharedApplication] registerForRemoteNotifications];
return YES;
}
Add below code in your didFinishLaunchingWithOptions in AppDelegate.m:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
working for me for iOS 9.0 and Xcode 7.2.

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])

Problems displaying UIAlertView from notification when app is closed

I have the following code that I use for push notifications:
located within my appdelegate.m is the following code
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
//Register to receive notifcations
//-- Set Notification
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
[Pushbots getInstance];
NSDictionary * userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if(userInfo) {
// Notification Message
NSString* notificationMsg = [userInfo valueForKey:#"message"];
// Custom Field
NSString* title = [userInfo valueForKey:#"title"];
NSLog(#"Notification Msg is %# and Custom field title = %#", notificationMsg , title);
}
return YES;
}
-(void)onReceivePushNotification:(NSDictionary *) pushDict andPayload:(NSDictionary *)payload {
[payload valueForKey:#"title"];
UIAlertView *message = [[UIAlertView alloc] initWithTitle:#"New Alert !" message:[pushDict valueForKey:#"alert"] delegate:self cancelButtonTitle:#"Thanks !" otherButtonTitles: #"Open",nil];
[message show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:#"Open"]) {
[[Pushbots getInstance] OpenedNotification];
// set Badge to 0
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
// reset badge on the server
[[Pushbots getInstance] resetBadgeCount];
}
}
This code works fine when the application is not closed, it presents me with the notification alert view.
HOWEVER it does not work properly when the application is closed fully and not running in background.
And I dont know what to do about it!
Thanks in advance?
you cannot since displaying an alert view required the notification invoking some part of your code, however the entry point for your code i.e. where you may first handle anything regarding your notification is on
(BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary) launchOptions
which means your app has to be awake in order to show a custom alert view.
For now you will have to settle to the default implementation ios gives you, that is the notification bar at the top.
hope ts useful

Push Notification ON or OFF Checking in iOS

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".
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 the App once got registered with the registerForRemoteNotification, then you can disable as well as enable . Once you disable and you are about to Re-Regigister with it, then this will enable the registerForRemoteNotification, without Popup for a alert.
Technical Note TN2265: Troubleshooting Push Notifications
The first time a push-enabled app registers for push notifications, iOS
asks the user if they wish to receive notifications for that app. Once
the user has responded to this alert it is not presented again unless
the device is restored or the app has been uninstalled for at least a
day.
If you want to simulate a first-time run of your app, you can leave
the app uninstalled for a day. You can achieve the latter without
actually waiting a day by setting the system clock forward a day or
more, turning the device off completely, then turning the device back
on.
Fore More Info: INFO && Info 2
Edit : For checking with alert enable -
use
if (types & UIRemoteNotificationTypeAlert){}
instead of
if (types == UIRemoteNotificationTypeNone){}
Edit :
Latest update from the doc for iOS 8 or later, You can check out by :
- (BOOL)isRegisteredForRemoteNotifications
It's work for me. Hope this help! :D
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"8.0")){
UIUserNotificationType type = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];
if (type == UIUserNotificationTypeNone){
ALERT_WITH_TITLE(#"", kMessageNotificationTurnOnRequire);
}
}
else {
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types == UIRemoteNotificationTypeNone) {
ALERT_WITH_TITLE(#"", kMessageNotificationTurnOnRequire);
}
}
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");
}
}

Resources