Commit c02c926a by Sebastián Katzer

Fix iOS7 crash (#280)

parent fa87fdc5
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
*/ */
#import "APPLocalNotification.h" #import "APPLocalNotification.h"
#import <Cordova/CDVAvailability.h>
@interface APPLocalNotification (Private) @interface APPLocalNotification (Private)
...@@ -108,8 +109,8 @@ ...@@ -108,8 +109,8 @@
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC),
dispatch_get_main_queue(), ^{ dispatch_get_main_queue(), ^{
[self cancelNotification:notification fireEvent:NO]; [self cancelNotification:notification fireEvent:NO];
}); });
} }
[self scheduleNotificationWithProperties:properties]; [self scheduleNotificationWithProperties:properties];
...@@ -238,12 +239,14 @@ ...@@ -238,12 +239,14 @@
*/ */
- (void) promptForPermission:(CDVInvokedUrlCommand *)command - (void) promptForPermission:(CDVInvokedUrlCommand *)command
{ {
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { if (IsAtLeastiOSVersion(@"8.0")) {
UIUserNotificationType types = UIUserNotificationType types;
UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound; UIUserNotificationSettings *settings;
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types types = UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound;
categories:nil];
settings = [UIUserNotificationSettings settingsForTypes:types
categories:nil];
[self.commandDelegate runInBackground:^{ [self.commandDelegate runInBackground:^{
[[UIApplication sharedApplication] [[UIApplication sharedApplication]
...@@ -257,14 +260,16 @@ ...@@ -257,14 +260,16 @@
*/ */
- (BOOL) hasPermissionToSheduleNotifications - (BOOL) hasPermissionToSheduleNotifications
{ {
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { if (IsAtLeastiOSVersion(@"8.0")) {
UIUserNotificationSettings *settings = [[UIApplication sharedApplication] UIUserNotificationType types;
currentUserNotificationSettings]; UIUserNotificationSettings *settings;
settings = [[UIApplication sharedApplication]
currentUserNotificationSettings];
UIUserNotificationType requiredTypes = types = UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound;
UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound;
return (settings.types & requiredTypes); return (settings.types & types);
} else { } else {
return YES; return YES;
} }
......
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