|
|
@@ -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];
|
|
|
}
|
|
|
|