From 7765dfc67efec8e825fc48fdc0f0c600f633d4da Mon Sep 17 00:00:00 2001 From: krisrandall Date: Wed, 27 May 2015 12:33:42 +1000 Subject: [PATCH] fix for iOS8 (from http://stackoverflow.com/a/26397526/1290746) --- src/ios/PushPlugin.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ios/PushPlugin.m b/src/ios/PushPlugin.m index 7686ae9d..3140ca1c 100644 --- a/src/ios/PushPlugin.m +++ b/src/ios/PushPlugin.m @@ -142,6 +142,8 @@ - (void)isEnabled:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)op } */ +#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) + - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSMutableDictionary *results = [NSMutableDictionary dictionary]; @@ -156,7 +158,13 @@ - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [results setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] forKey:@"appVersion"]; // Check what Notifications the user has turned on. We registered for all three, but they may have manually disabled some or all of them. - NSUInteger rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; + //NSUInteger rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; + NSUInteger rntypes; + if (!SYSTEM_VERSION_LESS_THAN(@"8.0")) { + rntypes = [[[UIApplication sharedApplication] currentUserNotificationSettings] types]; + }else{ + rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; + } // Set the defaults to disabled unless we find otherwise... NSString *pushBadge = @"disabled";