From d11985984d8f9c335ff4f09199cf4a82dcfee083 Mon Sep 17 00:00:00 2001 From: gdorigo Date: Tue, 25 Oct 2016 14:21:26 +0200 Subject: [PATCH] fix issue #354 (enabledRemoteNotificationTypes is not supported in iOS 8 --- 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 c546c5d8..d6fcb7d0 100644 --- a/src/ios/PushPlugin.m +++ b/src/ios/PushPlugin.m @@ -152,7 +152,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";