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)
...@@ -238,11 +239,13 @@ ...@@ -238,11 +239,13 @@
*/ */
- (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;
settings = [UIUserNotificationSettings settingsForTypes:types
categories:nil]; categories:nil];
[self.commandDelegate runInBackground:^{ [self.commandDelegate runInBackground:^{
...@@ -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;
UIUserNotificationSettings *settings;
settings = [[UIApplication sharedApplication]
currentUserNotificationSettings]; 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