From 6cf2e1a107310e859839fb7a0dc2618a7a199430 Mon Sep 17 00:00:00 2001 From: Ross Martin Date: Sun, 2 Nov 2014 18:49:17 -0600 Subject: [PATCH] fix issue #354 (enabledRemoteNotificationTypes is not supported in iOS 8.0 and later.) --- src/ios/PushPlugin.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ios/PushPlugin.m b/src/ios/PushPlugin.m index 7686ae9d..ee9def38 100644 --- a/src/ios/PushPlugin.m +++ b/src/ios/PushPlugin.m @@ -156,7 +156,16 @@ - (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]; + + #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) + + 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";