Browse Source

Merge pull request #146 from TikiTDO/master

Fix RN import priority, favoring newest version of RN (Adds to #138 and #139)
Yonah Forst 8 years ago
parent
commit
75f1d797bc
3 changed files with 40 additions and 32 deletions
  1. 5 3
      RCTConvert+RNPStatus.h
  2. 5 3
      ReactNativePermissions.h
  3. 30 26
      ReactNativePermissions.m

+ 5 - 3
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(<React/RCTConvert.h>)
   #import <React/RCTConvert.h>
+#elif __has_include("React/RCTConvert.h")
+  #import "React/RCTConvert.h"
+#else
+  #import "RCTConvert.h"
 #endif
 
 static NSString* RNPStatusUndetermined = @"undetermined";

+ 5 - 3
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(<React/RCTBridgeModule.h>)
   #import <React/RCTBridgeModule.h>
+#elif __has_include("React/RCTBridgeModule.h")
+  #import "React/RCTBridgeModule.h"
+#else
+  #import "RCTBridgeModule.h"
 #endif
 
 @interface ReactNativePermissions : NSObject <RCTBridgeModule>

+ 30 - 26
ReactNativePermissions.m

@@ -12,23 +12,27 @@
 
 #if __has_include(<React/RCTBridge.h>)
   #import <React/RCTBridge.h>
-#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(<React/RCTConvert.h>)
   #import <React/RCTConvert.h>
+#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(<React/RCTEventDispatcher.h>)
   #import <React/RCTEventDispatcher.h>
+#elif __has_include("React/RCTEventDispatcher.h")
+  #import "React/RCTEventDispatcher.h"
+#else
+  #import "RCTEventDispatcher.h"
 #endif
 
 #import "RNPLocation.h"
@@ -59,7 +63,7 @@ RCT_EXPORT_MODULE();
 {
     if (self = [super init]) {
     }
-    
+
     return self;
 }
 
@@ -76,11 +80,11 @@ RCT_REMAP_METHOD(canOpenSettings, canOpenSettings:(RCTPromiseResolveBlock)resolv
     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 @@ RCT_EXPORT_METHOD(openSettings:(RCTPromiseResolveBlock)resolve rejecter:(RCTProm
                                                [center removeObserver:token];
                                                resolve(@YES);
                                            }];
-        
+
         NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
         [[UIApplication sharedApplication] openURL:url];
     }
@@ -99,9 +103,9 @@ RCT_EXPORT_METHOD(openSettings:(RCTPromiseResolveBlock)resolve rejecter:(RCTProm
 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 @@ RCT_REMAP_METHOD(getPermissionStatus, getPermissionStatus:(RNPType)type json:(id
 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 @@ RCT_REMAP_METHOD(requestPermission, permissionType:(RNPType)type json:(id)json r
         default:
             break;
     }
-    
+
 
 }
 
@@ -181,31 +185,31 @@ RCT_REMAP_METHOD(requestPermission, permissionType:(RNPType)type json:(id)json r
     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 @@ RCT_REMAP_METHOD(requestPermission, permissionType:(RNPType)type json:(id)json r
     if (self.bluetoothMgr == nil) {
         self.bluetoothMgr = [[RNPBluetooth alloc] init];
     }
-    
+
     [self.bluetoothMgr request:resolve];
 }