Commit 77eec598 authored by Sebastián Katzer's avatar Sebastián Katzer
Browse files

Check SDK version at runtime

parent 5416f1c7
Loading
Loading
Loading
Loading
+5 −6
Changes for src/ios/APPLocalNotification.m: 5 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -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 -
+9 −7
Changes for src/ios/UIApplication+APPLocalNotification.m: 9 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -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 -