This repository has been archived by the owner on Sep 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
623 additions
and
523 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
/* | ||
* Copyright (c) 2017 Mattia Panzeri <[email protected]> | ||
* Latest changes by Federico Boschini <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
export { NearItManager as default, constants as NearItConstants } from './lib/NearItManager' | ||
export { NearITPermissions } from './lib/permissions' |
Binary file not shown.
Binary file modified
BIN
-4 Bytes
(100%)
ios/NearITSDK/NearITResources.bundle/NITEnrollDeviceViewController.nib/objects-11.0+.nib
Binary file not shown.
Binary file modified
BIN
+8 Bytes
(100%)
ios/NearITSDK/NearITResources.bundle/NITEnrollDeviceViewController.nib/runtime.nib
Binary file not shown.
Binary file not shown.
151 changes: 0 additions & 151 deletions
151
ios/NearITSDK/NearITResources.bundle/_CodeSignature/CodeResources
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2018 Federico Boschini <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#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* RNNStatusNeverAsked = @"never_asked"; | ||
static NSString* RNNStatusDenied = @"denied"; | ||
static NSString* RNNStatusGrantedAlways = @"always"; | ||
static NSString* RNNStatusGrantedWhenInUse = @"when_in_use"; | ||
|
||
typedef NS_ENUM(NSInteger, RNNPermissionType) { | ||
RNNPermissionTypeUnknown, | ||
RNNPermissionTypeLocation, | ||
RNNPermissionTypeNotification | ||
}; | ||
|
||
@interface RCTConvert (RNNPermissionStatus) | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (c) 2018 Federico Boschini <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#import "RCTConvert+RNNPermissionStatus.h" | ||
|
||
@implementation RCTConvert (RNNPermissionStatus) | ||
|
||
RCT_ENUM_CONVERTER(RNNPermissionType, (@{ @"location" : @(RNNPermissionTypeLocation), | ||
@"notification" : @(RNNPermissionTypeNotification) | ||
}), | ||
RNNPermissionTypeUnknown, integerValue) | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) 2018 Federico Boschini <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "RCTConvert+RNNPermissionStatus.h" | ||
|
||
@interface RNNLocationPermission : NSObject | ||
|
||
+ (NSString *)getStatus; | ||
- (void)requestWithCompletionHandler:(void (^)(NSString *))completionHandler; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (c) 2018 Federico Boschini <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#import "RNNLocationPermission.h" | ||
#import "RCTConvert+RNNPermissionStatus.h" | ||
#import <CoreLocation/CoreLocation.h> | ||
|
||
@interface RNNLocationPermission() <CLLocationManagerDelegate> | ||
@property (strong, nonatomic) CLLocationManager* locationManager; | ||
@property (copy) void (^completionHandler)(NSString *); | ||
@end | ||
|
||
@implementation RNNLocationPermission | ||
|
||
+ (NSString *)getStatus { | ||
int status = [CLLocationManager authorizationStatus]; | ||
switch (status) { | ||
case kCLAuthorizationStatusAuthorizedAlways: | ||
return RNNStatusGrantedAlways; | ||
case kCLAuthorizationStatusAuthorizedWhenInUse: | ||
return RNNStatusGrantedWhenInUse; | ||
case kCLAuthorizationStatusNotDetermined: | ||
return RNNStatusNeverAsked; | ||
default: | ||
return RNNStatusDenied; | ||
} | ||
} | ||
|
||
- (void)requestWithCompletionHandler:(void (^)(NSString *))completionHandler { | ||
NSString *status = [self.class getStatus]; | ||
if ([status isEqualToString:RNNStatusNeverAsked]) { | ||
self.completionHandler = completionHandler; | ||
|
||
if (self.locationManager == nil) { | ||
self.locationManager = [[CLLocationManager alloc] init]; | ||
self.locationManager.delegate = self; | ||
} | ||
|
||
[self.locationManager requestAlwaysAuthorization]; | ||
} else if ([status isEqualToString:RNNStatusDenied]) { | ||
if (@(UIApplicationOpenSettingsURLString != nil)) { | ||
|
||
NSNotificationCenter * __weak center = [NSNotificationCenter defaultCenter]; | ||
id __block token = [center addObserverForName:UIApplicationDidBecomeActiveNotification | ||
object:nil | ||
queue:nil | ||
usingBlock:^(NSNotification *note) { | ||
[center removeObserver:token]; | ||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ | ||
completionHandler(RNNLocationPermission.getStatus); | ||
}); | ||
}]; | ||
|
||
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; | ||
[[UIApplication sharedApplication] openURL:url]; | ||
} else { | ||
NSLog(@"E_OPEN_SETTINGS_ERROR: Can't open app settings"); | ||
completionHandler(status); | ||
} | ||
} else { | ||
completionHandler(status); | ||
} | ||
} | ||
|
||
-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { | ||
if (status != kCLAuthorizationStatusNotDetermined) { | ||
if (self.locationManager) { | ||
self.locationManager.delegate = nil; | ||
self.locationManager = nil; | ||
} | ||
|
||
if (self.completionHandler) { | ||
//for some reason, checking permission right away returns denied. need to wait a tiny bit | ||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ | ||
self.completionHandler([RNNLocationPermission getStatus]); | ||
self.completionHandler = nil; | ||
}); | ||
} | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) 2018 Federico Boschini <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "RCTConvert+RNNPermissionStatus.h" | ||
|
||
@interface RNNNotificationPermission : NSObject | ||
|
||
+ (NSString *)getStatus; | ||
- (void)requestWithCompletionHandler:(void (^)(NSString*))completionHandler; | ||
|
||
@end |
Oops, something went wrong.