From 008bc688ec2def970775353bfa93fdcf954f1017 Mon Sep 17 00:00:00 2001 From: Tikhon Botchkarev Date: Tue, 12 Sep 2017 00:34:32 -0400 Subject: [PATCH] Fix RN import priority, favoring newest version of RN --- RCTConvert+RNPStatus.h | 8 +++--- ReactNativePermissions.h | 8 +++--- ReactNativePermissions.m | 56 +++++++++++++++++++++------------------- 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/RCTConvert+RNPStatus.h b/RCTConvert+RNPStatus.h index f3b0fb13..db87a962 100644 --- a/RCTConvert+RNPStatus.h +++ b/RCTConvert+RNPStatus.h @@ -6,10 +6,12 @@ // Copyright © 2016 Yonah Forst. All rights reserved. // -#if __has_include("RCTConvert.h") - #import "RCTConvert.h" -#else +#if __has_include() #import +#elif __has_include("React/RCTConvert.h") + #import "React/RCTConvert.h" +#else + #import "RCTConvert.h" #endif static NSString* RNPStatusUndetermined = @"undetermined"; diff --git a/ReactNativePermissions.h b/ReactNativePermissions.h index 9059a39e..cb570f31 100644 --- a/ReactNativePermissions.h +++ b/ReactNativePermissions.h @@ -6,10 +6,12 @@ // Copyright © 2016 Yonah Forst. All rights reserved. // -#if __has_include("RCTBridgeModule.h") - #import "RCTBridgeModule.h" -#else +#if __has_include() #import +#elif __has_include("React/RCTBridgeModule.h") + #import "React/RCTBridgeModule.h" +#else + #import "RCTBridgeModule.h" #endif @interface ReactNativePermissions : NSObject diff --git a/ReactNativePermissions.m b/ReactNativePermissions.m index 1284038e..e190951c 100644 --- a/ReactNativePermissions.m +++ b/ReactNativePermissions.m @@ -12,23 +12,27 @@ #if __has_include() #import -#elif __has_include("RCTBridge.h") - #import "RCTBridge.h" -#else +#elif __has_include("React/RCTBridge.h") #import "React/RCTBridge.h" +#else + #import "RCTBridge.h" #endif -#if __has_include("RCTConvert.h") - #import "RCTConvert.h" -#else +#if __has_include() #import +#elif __has_include("React/RCTConvert.h") + #import "React/RCTConvert.h" +#else + #import "RCTConvert.h" #endif -#if __has_include("RCTEventDispatcher.h") - #import "RCTEventDispatcher.h" -#else +#if __has_include() #import +#elif __has_include("React/RCTEventDispatcher.h") + #import "React/RCTEventDispatcher.h" +#else + #import "RCTEventDispatcher.h" #endif #import "RNPLocation.h" @@ -59,7 +63,7 @@ - (instancetype)init { if (self = [super init]) { } - + return self; } @@ -76,11 +80,11 @@ - (dispatch_queue_t)methodQueue { resolve(@(UIApplicationOpenSettingsURLString != nil)); } - + RCT_EXPORT_METHOD(openSettings:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { if (@(UIApplicationOpenSettingsURLString != nil)) { - + NSNotificationCenter * __weak center = [NSNotificationCenter defaultCenter]; id __block token = [center addObserverForName:UIApplicationDidBecomeActiveNotification object:nil @@ -89,7 +93,7 @@ - (dispatch_queue_t)methodQueue { [center removeObserver:token]; resolve(@YES); }]; - + NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; [[UIApplication sharedApplication] openURL:url]; } @@ -99,9 +103,9 @@ - (dispatch_queue_t)methodQueue { RCT_REMAP_METHOD(getPermissionStatus, getPermissionStatus:(RNPType)type json:(id)json resolve:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { NSString *status; - + switch (type) { - + case RNPTypeLocation: { NSString *locationPermissionType = [RCTConvert NSString:json]; status = [RNPLocation getStatusForType:locationPermissionType]; @@ -147,7 +151,7 @@ - (dispatch_queue_t)methodQueue { RCT_REMAP_METHOD(requestPermission, permissionType:(RNPType)type json:(id)json resolve:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { NSString *status; - + switch (type) { case RNPTypeLocation: return [self requestLocation:json resolve:resolve]; @@ -172,7 +176,7 @@ - (dispatch_queue_t)methodQueue { default: break; } - + } @@ -181,31 +185,31 @@ - (void) requestLocation:(id)json resolve:(RCTPromiseResolveBlock)resolve if (self.locationMgr == nil) { self.locationMgr = [[RNPLocation alloc] init]; } - + NSString *type = [RCTConvert NSString:json]; - + [self.locationMgr request:type completionHandler:resolve]; } - (void) requestNotification:(id)json resolve:(RCTPromiseResolveBlock)resolve { NSArray *typeStrings = [RCTConvert NSArray:json]; - + UIUserNotificationType types; if ([typeStrings containsObject:@"alert"]) types = types | UIUserNotificationTypeAlert; - + if ([typeStrings containsObject:@"badge"]) types = types | UIUserNotificationTypeBadge; - + if ([typeStrings containsObject:@"sound"]) types = types | UIUserNotificationTypeSound; - - + + if (self.notificationMgr == nil) { self.notificationMgr = [[RNPNotification alloc] init]; } - + [self.notificationMgr request:types completionHandler:resolve]; } @@ -216,7 +220,7 @@ - (void) requestBluetooth:(RCTPromiseResolveBlock)resolve if (self.bluetoothMgr == nil) { self.bluetoothMgr = [[RNPBluetooth alloc] init]; } - + [self.bluetoothMgr request:resolve]; }