Commit 77eec598 by Sebastián Katzer

Check SDK version at runtime

parent 5416f1c7
......@@ -27,8 +27,6 @@
#import "UIApplication+APPLocalNotification.h"
#import "UILocalNotification+APPLocalNotification.h"
#import <Availability.h>
@interface APPLocalNotification ()
// Retrieves the application state
......@@ -411,16 +409,17 @@
*/
- (void) registerPermission:(CDVInvokedUrlCommand*)command
{
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if ([[UIApplication sharedApplication]
respondsToSelector:@selector(registerUserNotificationSettings:)])
{
_command = command;
[self.commandDelegate runInBackground:^{
[self.app registerPermissionToScheduleLocalNotifications];
}];
#else
} else {
[self hasPermission:command];
#endif
}
}
#pragma mark -
......
......@@ -24,8 +24,6 @@
#import "UIApplication+APPLocalNotification.h"
#import "UILocalNotification+APPLocalNotification.h"
#import <Availability.h>
@implementation UIApplication (APPLocalNotification)
#pragma mark -
......@@ -36,7 +34,9 @@
*/
- (BOOL) hasPermissionToScheduleLocalNotifications
{
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if ([[UIApplication sharedApplication]
respondsToSelector:@selector(registerUserNotificationSettings:)])
{
UIUserNotificationType types;
UIUserNotificationSettings *settings;
......@@ -46,9 +46,9 @@
types = UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound;
return (settings.types & types);
#else
} else {
return YES;
#endif
}
}
/**
......@@ -56,7 +56,9 @@
*/
- (void) registerPermissionToScheduleLocalNotifications
{
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if ([[UIApplication sharedApplication]
respondsToSelector:@selector(registerUserNotificationSettings:)])
{
UIUserNotificationType types;
UIUserNotificationSettings *settings;
......@@ -67,7 +69,7 @@
[[UIApplication sharedApplication]
registerUserNotificationSettings:settings];
#endif
}
}
#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