Procházet zdrojové kódy

Fix RN import priority, favoring newest version of RN

Tikhon Botchkarev před 7 roky
rodič
revize
008bc688ec
3 změnil soubory, kde provedl 40 přidání a 32 odebrání
  1. 5
    3
      RCTConvert+RNPStatus.h
  2. 5
    3
      ReactNativePermissions.h
  3. 30
    26
      ReactNativePermissions.m

+ 5
- 3
RCTConvert+RNPStatus.h Zobrazit soubor

@@ -6,10 +6,12 @@
6 6
 //  Copyright © 2016 Yonah Forst. All rights reserved.
7 7
 //
8 8
 
9
-#if __has_include("RCTConvert.h")
10
-  #import "RCTConvert.h"
11
-#else
9
+#if __has_include(<React/RCTConvert.h>)
12 10
   #import <React/RCTConvert.h>
11
+#elif __has_include("React/RCTConvert.h")
12
+  #import "React/RCTConvert.h"
13
+#else
14
+  #import "RCTConvert.h"
13 15
 #endif
14 16
 
15 17
 static NSString* RNPStatusUndetermined = @"undetermined";

+ 5
- 3
ReactNativePermissions.h Zobrazit soubor

@@ -6,10 +6,12 @@
6 6
 //  Copyright © 2016 Yonah Forst. All rights reserved.
7 7
 //
8 8
 
9
-#if __has_include("RCTBridgeModule.h")
10
-  #import "RCTBridgeModule.h"
11
-#else
9
+#if __has_include(<React/RCTBridgeModule.h>)
12 10
   #import <React/RCTBridgeModule.h>
11
+#elif __has_include("React/RCTBridgeModule.h")
12
+  #import "React/RCTBridgeModule.h"
13
+#else
14
+  #import "RCTBridgeModule.h"
13 15
 #endif
14 16
 
15 17
 @interface ReactNativePermissions : NSObject <RCTBridgeModule>

+ 30
- 26
ReactNativePermissions.m Zobrazit soubor

@@ -12,23 +12,27 @@
12 12
 
13 13
 #if __has_include(<React/RCTBridge.h>)
14 14
   #import <React/RCTBridge.h>
15
-#elif __has_include("RCTBridge.h")
16
-  #import "RCTBridge.h"
17
-#else
15
+#elif __has_include("React/RCTBridge.h")
18 16
   #import "React/RCTBridge.h"
17
+#else
18
+  #import "RCTBridge.h"
19 19
 #endif
20 20
 
21 21
 
22
-#if __has_include("RCTConvert.h")
23
-  #import "RCTConvert.h"
24
-#else
22
+#if __has_include(<React/RCTConvert.h>)
25 23
   #import <React/RCTConvert.h>
24
+#elif __has_include("React/RCTConvert.h")
25
+  #import "React/RCTConvert.h"
26
+#else
27
+  #import "RCTConvert.h"
26 28
 #endif
27 29
 
28
-#if __has_include("RCTEventDispatcher.h")
29
-  #import "RCTEventDispatcher.h"
30
-#else
30
+#if __has_include(<React/RCTEventDispatcher.h>)
31 31
   #import <React/RCTEventDispatcher.h>
32
+#elif __has_include("React/RCTEventDispatcher.h")
33
+  #import "React/RCTEventDispatcher.h"
34
+#else
35
+  #import "RCTEventDispatcher.h"
32 36
 #endif
33 37
 
34 38
 #import "RNPLocation.h"
@@ -59,7 +63,7 @@ RCT_EXPORT_MODULE();
59 63
 {
60 64
     if (self = [super init]) {
61 65
     }
62
-    
66
+
63 67
     return self;
64 68
 }
65 69
 
@@ -76,11 +80,11 @@ RCT_REMAP_METHOD(canOpenSettings, canOpenSettings:(RCTPromiseResolveBlock)resolv
76 80
     resolve(@(UIApplicationOpenSettingsURLString != nil));
77 81
 }
78 82
 
79
-    
83
+
80 84
 RCT_EXPORT_METHOD(openSettings:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
81 85
 {
82 86
     if (@(UIApplicationOpenSettingsURLString != nil)) {
83
-        
87
+
84 88
         NSNotificationCenter * __weak center = [NSNotificationCenter defaultCenter];
85 89
         id __block token = [center addObserverForName:UIApplicationDidBecomeActiveNotification
86 90
                                                object:nil
@@ -89,7 +93,7 @@ RCT_EXPORT_METHOD(openSettings:(RCTPromiseResolveBlock)resolve rejecter:(RCTProm
89 93
                                                [center removeObserver:token];
90 94
                                                resolve(@YES);
91 95
                                            }];
92
-        
96
+
93 97
         NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
94 98
         [[UIApplication sharedApplication] openURL:url];
95 99
     }
@@ -99,9 +103,9 @@ RCT_EXPORT_METHOD(openSettings:(RCTPromiseResolveBlock)resolve rejecter:(RCTProm
99 103
 RCT_REMAP_METHOD(getPermissionStatus, getPermissionStatus:(RNPType)type json:(id)json resolve:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
100 104
 {
101 105
     NSString *status;
102
-    
106
+
103 107
     switch (type) {
104
-            
108
+
105 109
         case RNPTypeLocation: {
106 110
             NSString *locationPermissionType = [RCTConvert NSString:json];
107 111
             status = [RNPLocation getStatusForType:locationPermissionType];
@@ -147,7 +151,7 @@ RCT_REMAP_METHOD(getPermissionStatus, getPermissionStatus:(RNPType)type json:(id
147 151
 RCT_REMAP_METHOD(requestPermission, permissionType:(RNPType)type json:(id)json resolve:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
148 152
 {
149 153
     NSString *status;
150
-    
154
+
151 155
     switch (type) {
152 156
         case RNPTypeLocation:
153 157
             return [self requestLocation:json resolve:resolve];
@@ -172,7 +176,7 @@ RCT_REMAP_METHOD(requestPermission, permissionType:(RNPType)type json:(id)json r
172 176
         default:
173 177
             break;
174 178
     }
175
-    
179
+
176 180
 
177 181
 }
178 182
 
@@ -181,31 +185,31 @@ RCT_REMAP_METHOD(requestPermission, permissionType:(RNPType)type json:(id)json r
181 185
     if (self.locationMgr == nil) {
182 186
         self.locationMgr = [[RNPLocation alloc] init];
183 187
     }
184
-    
188
+
185 189
     NSString *type = [RCTConvert NSString:json];
186
-    
190
+
187 191
     [self.locationMgr request:type completionHandler:resolve];
188 192
 }
189 193
 
190 194
 - (void) requestNotification:(id)json resolve:(RCTPromiseResolveBlock)resolve
191 195
 {
192 196
     NSArray *typeStrings = [RCTConvert NSArray:json];
193
-    
197
+
194 198
     UIUserNotificationType types;
195 199
     if ([typeStrings containsObject:@"alert"])
196 200
         types = types | UIUserNotificationTypeAlert;
197
-    
201
+
198 202
     if ([typeStrings containsObject:@"badge"])
199 203
         types = types | UIUserNotificationTypeBadge;
200
-    
204
+
201 205
     if ([typeStrings containsObject:@"sound"])
202 206
         types = types | UIUserNotificationTypeSound;
203
-    
204
-    
207
+
208
+
205 209
     if (self.notificationMgr == nil) {
206 210
         self.notificationMgr = [[RNPNotification alloc] init];
207 211
     }
208
-    
212
+
209 213
     [self.notificationMgr request:types completionHandler:resolve];
210 214
 
211 215
 }
@@ -216,7 +220,7 @@ RCT_REMAP_METHOD(requestPermission, permissionType:(RNPType)type json:(id)json r
216 220
     if (self.bluetoothMgr == nil) {
217 221
         self.bluetoothMgr = [[RNPBluetooth alloc] init];
218 222
     }
219
-    
223
+
220 224
     [self.bluetoothMgr request:resolve];
221 225
 }
222 226