Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Commit 00a2f27

Browse files
Merge branch 'hotfix/v2.9.0-beta.2'
2 parents bc7514d + 7e40176 commit 00a2f27

28 files changed

+623
-523
lines changed

android/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ buildscript {
1313
}
1414

1515
dependencies {
16-
classpath 'com.android.tools.build:gradle:3.1.3'
16+
classpath 'com.android.tools.build:gradle:3.1.4'
1717
}
1818
}
1919

@@ -34,7 +34,7 @@ android {
3434

3535
defaultConfig {
3636
minSdkVersion 16
37-
targetSdkVersion 22
37+
targetSdkVersion 27
3838
}
3939

4040
lintOptions {
@@ -45,5 +45,5 @@ android {
4545

4646
dependencies {
4747
implementation 'com.facebook.react:react-native:+'
48-
api 'it.near.sdk:nearit:2.9.4'
48+
api 'it.near.sdk:nearit:2.9.5'
4949
}

android/src/main/java/it/near/sdk/reactnative/rnnearitsdk/RNNearItModule.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ private Map<String, Object> getEventContentConstants() {
175175
private Map<String, Object> getStatusConstants() {
176176
return Collections.unmodifiableMap(new HashMap<String, Object>() {
177177
{
178-
put("notified", Recipe.RECEIVED);
179-
put("engaged", Recipe.OPENED);
178+
put("received", Recipe.RECEIVED);
179+
put("opened", Recipe.OPENED);
180180
}
181181
});
182182
}

index.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ declare module 'react-native-nearit' {
2626
}
2727

2828
interface NearItStatuses {
29-
notified: string
30-
engaged: string
29+
received: string
30+
opened: string
3131
}
3232

3333
interface NearItEvent {

index.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/*
22
* Copyright (c) 2017 Mattia Panzeri <[email protected]>
3+
* Latest changes by Federico Boschini <[email protected]>
34
*
45
* This Source Code Form is subject to the terms of the Mozilla Public
56
* License, v. 2.0. If a copy of the MPL was not distributed with this
67
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
78
*/
89

910
export { NearItManager as default, constants as NearItConstants } from './lib/NearItManager'
11+
export { NearITPermissions } from './lib/permissions'
-30 Bytes
Binary file not shown.
Binary file not shown.

ios/NearITSDK/NearITResources.bundle/_CodeSignature/CodeResources

-151
This file was deleted.

ios/NearITSDK/libNearIT.a

3.3 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2018 Federico Boschini <[email protected]>
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7+
*/
8+
9+
#if __has_include(<React/RCTConvert.h>)
10+
#import <React/RCTConvert.h>
11+
#elif __has_include("React/RCTConvert.h")
12+
#import "React/RCTConvert.h"
13+
#else
14+
#import "RCTConvert.h"
15+
#endif
16+
17+
static NSString* RNNStatusNeverAsked = @"never_asked";
18+
static NSString* RNNStatusDenied = @"denied";
19+
static NSString* RNNStatusGrantedAlways = @"always";
20+
static NSString* RNNStatusGrantedWhenInUse = @"when_in_use";
21+
22+
typedef NS_ENUM(NSInteger, RNNPermissionType) {
23+
RNNPermissionTypeUnknown,
24+
RNNPermissionTypeLocation,
25+
RNNPermissionTypeNotification
26+
};
27+
28+
@interface RCTConvert (RNNPermissionStatus)
29+
30+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2018 Federico Boschini <[email protected]>
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7+
*/
8+
9+
#import "RCTConvert+RNNPermissionStatus.h"
10+
11+
@implementation RCTConvert (RNNPermissionStatus)
12+
13+
RCT_ENUM_CONVERTER(RNNPermissionType, (@{ @"location" : @(RNNPermissionTypeLocation),
14+
@"notification" : @(RNNPermissionTypeNotification)
15+
}),
16+
RNNPermissionTypeUnknown, integerValue)
17+
18+
@end
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2018 Federico Boschini <[email protected]>
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7+
*/
8+
9+
#import <Foundation/Foundation.h>
10+
#import "RCTConvert+RNNPermissionStatus.h"
11+
12+
@interface RNNLocationPermission : NSObject
13+
14+
+ (NSString *)getStatus;
15+
- (void)requestWithCompletionHandler:(void (^)(NSString *))completionHandler;
16+
17+
@end
+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright (c) 2018 Federico Boschini <[email protected]>
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7+
*/
8+
9+
#import "RNNLocationPermission.h"
10+
#import "RCTConvert+RNNPermissionStatus.h"
11+
#import <CoreLocation/CoreLocation.h>
12+
13+
@interface RNNLocationPermission() <CLLocationManagerDelegate>
14+
@property (strong, nonatomic) CLLocationManager* locationManager;
15+
@property (copy) void (^completionHandler)(NSString *);
16+
@end
17+
18+
@implementation RNNLocationPermission
19+
20+
+ (NSString *)getStatus {
21+
int status = [CLLocationManager authorizationStatus];
22+
switch (status) {
23+
case kCLAuthorizationStatusAuthorizedAlways:
24+
return RNNStatusGrantedAlways;
25+
case kCLAuthorizationStatusAuthorizedWhenInUse:
26+
return RNNStatusGrantedWhenInUse;
27+
case kCLAuthorizationStatusNotDetermined:
28+
return RNNStatusNeverAsked;
29+
default:
30+
return RNNStatusDenied;
31+
}
32+
}
33+
34+
- (void)requestWithCompletionHandler:(void (^)(NSString *))completionHandler {
35+
NSString *status = [self.class getStatus];
36+
if ([status isEqualToString:RNNStatusNeverAsked]) {
37+
self.completionHandler = completionHandler;
38+
39+
if (self.locationManager == nil) {
40+
self.locationManager = [[CLLocationManager alloc] init];
41+
self.locationManager.delegate = self;
42+
}
43+
44+
[self.locationManager requestAlwaysAuthorization];
45+
} else if ([status isEqualToString:RNNStatusDenied]) {
46+
if (@(UIApplicationOpenSettingsURLString != nil)) {
47+
48+
NSNotificationCenter * __weak center = [NSNotificationCenter defaultCenter];
49+
id __block token = [center addObserverForName:UIApplicationDidBecomeActiveNotification
50+
object:nil
51+
queue:nil
52+
usingBlock:^(NSNotification *note) {
53+
[center removeObserver:token];
54+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
55+
completionHandler(RNNLocationPermission.getStatus);
56+
});
57+
}];
58+
59+
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
60+
[[UIApplication sharedApplication] openURL:url];
61+
} else {
62+
NSLog(@"E_OPEN_SETTINGS_ERROR: Can't open app settings");
63+
completionHandler(status);
64+
}
65+
} else {
66+
completionHandler(status);
67+
}
68+
}
69+
70+
-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
71+
if (status != kCLAuthorizationStatusNotDetermined) {
72+
if (self.locationManager) {
73+
self.locationManager.delegate = nil;
74+
self.locationManager = nil;
75+
}
76+
77+
if (self.completionHandler) {
78+
//for some reason, checking permission right away returns denied. need to wait a tiny bit
79+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
80+
self.completionHandler([RNNLocationPermission getStatus]);
81+
self.completionHandler = nil;
82+
});
83+
}
84+
}
85+
}
86+
87+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2018 Federico Boschini <[email protected]>
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7+
*/
8+
9+
#import <Foundation/Foundation.h>
10+
#import "RCTConvert+RNNPermissionStatus.h"
11+
12+
@interface RNNNotificationPermission : NSObject
13+
14+
+ (NSString *)getStatus;
15+
- (void)requestWithCompletionHandler:(void (^)(NSString*))completionHandler;
16+
17+
@end

0 commit comments

Comments
 (0)