Commit 77eec598 by Sebastián Katzer

Check SDK version at runtime

parent 5416f1c7
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#import "UIApplication+APPLocalNotification.h" #import "UIApplication+APPLocalNotification.h"
#import "UILocalNotification+APPLocalNotification.h" #import "UILocalNotification+APPLocalNotification.h"
#import <Availability.h>
@interface APPLocalNotification () @interface APPLocalNotification ()
// Retrieves the application state // Retrieves the application state
...@@ -411,16 +409,17 @@ ...@@ -411,16 +409,17 @@
*/ */
- (void) registerPermission:(CDVInvokedUrlCommand*)command - (void) registerPermission:(CDVInvokedUrlCommand*)command
{ {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 if ([[UIApplication sharedApplication]
respondsToSelector:@selector(registerUserNotificationSettings:)])
{
_command = command; _command = command;
[self.commandDelegate runInBackground:^{ [self.commandDelegate runInBackground:^{
[self.app registerPermissionToScheduleLocalNotifications]; [self.app registerPermissionToScheduleLocalNotifications];
}]; }];
#else } else {
[self hasPermission:command]; [self hasPermission:command];
#endif }
} }
#pragma mark - #pragma mark -
......
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
#import "UIApplication+APPLocalNotification.h" #import "UIApplication+APPLocalNotification.h"
#import "UILocalNotification+APPLocalNotification.h" #import "UILocalNotification+APPLocalNotification.h"
#import <Availability.h>
@implementation UIApplication (APPLocalNotification) @implementation UIApplication (APPLocalNotification)
#pragma mark - #pragma mark -
...@@ -36,7 +34,9 @@ ...@@ -36,7 +34,9 @@
*/ */
- (BOOL) hasPermissionToScheduleLocalNotifications - (BOOL) hasPermissionToScheduleLocalNotifications
{ {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 if ([[UIApplication sharedApplication]
respondsToSelector:@selector(registerUserNotificationSettings:)])
{
UIUserNotificationType types; UIUserNotificationType types;
UIUserNotificationSettings *settings; UIUserNotificationSettings *settings;
...@@ -46,9 +46,9 @@ ...@@ -46,9 +46,9 @@
types = UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound; types = UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound;
return (settings.types & types); return (settings.types & types);
#else } else {
return YES; return YES;
#endif }
} }
/** /**
...@@ -56,7 +56,9 @@ ...@@ -56,7 +56,9 @@
*/ */
- (void) registerPermissionToScheduleLocalNotifications - (void) registerPermissionToScheduleLocalNotifications
{ {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 if ([[UIApplication sharedApplication]
respondsToSelector:@selector(registerUserNotificationSettings:)])
{
UIUserNotificationType types; UIUserNotificationType types;
UIUserNotificationSettings *settings; UIUserNotificationSettings *settings;
...@@ -67,7 +69,7 @@ ...@@ -67,7 +69,7 @@
[[UIApplication sharedApplication] [[UIApplication sharedApplication]
registerUserNotificationSettings:settings]; registerUserNotificationSettings:settings];
#endif }
} }
#pragma mark - #pragma mark -
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment