Skip to content

Commit 75f1d79

Browse files
authored
Merge pull request #146 from TikiTDO/master
Fix RN import priority, favoring newest version of RN (Adds to #138 and #139)
2 parents 34e035a + 008bc68 commit 75f1d79

File tree

3 files changed

+40
-32
lines changed

3 files changed

+40
-32
lines changed

RCTConvert+RNPStatus.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
// Copyright © 2016 Yonah Forst. All rights reserved.
77
//
88

9-
#if __has_include("RCTConvert.h")
10-
#import "RCTConvert.h"
11-
#else
9+
#if __has_include(<React/RCTConvert.h>)
1210
#import <React/RCTConvert.h>
11+
#elif __has_include("React/RCTConvert.h")
12+
#import "React/RCTConvert.h"
13+
#else
14+
#import "RCTConvert.h"
1315
#endif
1416

1517
static NSString* RNPStatusUndetermined = @"undetermined";

ReactNativePermissions.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
// Copyright © 2016 Yonah Forst. All rights reserved.
77
//
88

9-
#if __has_include("RCTBridgeModule.h")
10-
#import "RCTBridgeModule.h"
11-
#else
9+
#if __has_include(<React/RCTBridgeModule.h>)
1210
#import <React/RCTBridgeModule.h>
11+
#elif __has_include("React/RCTBridgeModule.h")
12+
#import "React/RCTBridgeModule.h"
13+
#else
14+
#import "RCTBridgeModule.h"
1315
#endif
1416

1517
@interface ReactNativePermissions : NSObject <RCTBridgeModule>

ReactNativePermissions.m

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,27 @@
1212

1313
#if __has_include(<React/RCTBridge.h>)
1414
#import <React/RCTBridge.h>
15-
#elif __has_include("RCTBridge.h")
16-
#import "RCTBridge.h"
17-
#else
15+
#elif __has_include("React/RCTBridge.h")
1816
#import "React/RCTBridge.h"
17+
#else
18+
#import "RCTBridge.h"
1919
#endif
2020

2121

22-
#if __has_include("RCTConvert.h")
23-
#import "RCTConvert.h"
24-
#else
22+
#if __has_include(<React/RCTConvert.h>)
2523
#import <React/RCTConvert.h>
24+
#elif __has_include("React/RCTConvert.h")
25+
#import "React/RCTConvert.h"
26+
#else
27+
#import "RCTConvert.h"
2628
#endif
2729

28-
#if __has_include("RCTEventDispatcher.h")
29-
#import "RCTEventDispatcher.h"
30-
#else
30+
#if __has_include(<React/RCTEventDispatcher.h>)
3131
#import <React/RCTEventDispatcher.h>
32+
#elif __has_include("React/RCTEventDispatcher.h")
33+
#import "React/RCTEventDispatcher.h"
34+
#else
35+
#import "RCTEventDispatcher.h"
3236
#endif
3337

3438
#import "RNPLocation.h"
@@ -59,7 +63,7 @@ - (instancetype)init
5963
{
6064
if (self = [super init]) {
6165
}
62-
66+
6367
return self;
6468
}
6569

@@ -76,11 +80,11 @@ - (dispatch_queue_t)methodQueue {
7680
resolve(@(UIApplicationOpenSettingsURLString != nil));
7781
}
7882

79-
83+
8084
RCT_EXPORT_METHOD(openSettings:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
8185
{
8286
if (@(UIApplicationOpenSettingsURLString != nil)) {
83-
87+
8488
NSNotificationCenter * __weak center = [NSNotificationCenter defaultCenter];
8589
id __block token = [center addObserverForName:UIApplicationDidBecomeActiveNotification
8690
object:nil
@@ -89,7 +93,7 @@ - (dispatch_queue_t)methodQueue {
8993
[center removeObserver:token];
9094
resolve(@YES);
9195
}];
92-
96+
9397
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
9498
[[UIApplication sharedApplication] openURL:url];
9599
}
@@ -99,9 +103,9 @@ - (dispatch_queue_t)methodQueue {
99103
RCT_REMAP_METHOD(getPermissionStatus, getPermissionStatus:(RNPType)type json:(id)json resolve:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
100104
{
101105
NSString *status;
102-
106+
103107
switch (type) {
104-
108+
105109
case RNPTypeLocation: {
106110
NSString *locationPermissionType = [RCTConvert NSString:json];
107111
status = [RNPLocation getStatusForType:locationPermissionType];
@@ -147,7 +151,7 @@ - (dispatch_queue_t)methodQueue {
147151
RCT_REMAP_METHOD(requestPermission, permissionType:(RNPType)type json:(id)json resolve:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
148152
{
149153
NSString *status;
150-
154+
151155
switch (type) {
152156
case RNPTypeLocation:
153157
return [self requestLocation:json resolve:resolve];
@@ -172,7 +176,7 @@ - (dispatch_queue_t)methodQueue {
172176
default:
173177
break;
174178
}
175-
179+
176180

177181
}
178182

@@ -181,31 +185,31 @@ - (void) requestLocation:(id)json resolve:(RCTPromiseResolveBlock)resolve
181185
if (self.locationMgr == nil) {
182186
self.locationMgr = [[RNPLocation alloc] init];
183187
}
184-
188+
185189
NSString *type = [RCTConvert NSString:json];
186-
190+
187191
[self.locationMgr request:type completionHandler:resolve];
188192
}
189193

190194
- (void) requestNotification:(id)json resolve:(RCTPromiseResolveBlock)resolve
191195
{
192196
NSArray *typeStrings = [RCTConvert NSArray:json];
193-
197+
194198
UIUserNotificationType types;
195199
if ([typeStrings containsObject:@"alert"])
196200
types = types | UIUserNotificationTypeAlert;
197-
201+
198202
if ([typeStrings containsObject:@"badge"])
199203
types = types | UIUserNotificationTypeBadge;
200-
204+
201205
if ([typeStrings containsObject:@"sound"])
202206
types = types | UIUserNotificationTypeSound;
203-
204-
207+
208+
205209
if (self.notificationMgr == nil) {
206210
self.notificationMgr = [[RNPNotification alloc] init];
207211
}
208-
212+
209213
[self.notificationMgr request:types completionHandler:resolve];
210214

211215
}
@@ -216,7 +220,7 @@ - (void) requestBluetooth:(RCTPromiseResolveBlock)resolve
216220
if (self.bluetoothMgr == nil) {
217221
self.bluetoothMgr = [[RNPBluetooth alloc] init];
218222
}
219-
223+
220224
[self.bluetoothMgr request:resolve];
221225
}
222226

0 commit comments

Comments
 (0)