react-native-radar 3.20.0 → 3.20.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/android/build.gradle
CHANGED
|
@@ -96,7 +96,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
96
96
|
this.fraud = fraud;
|
|
97
97
|
SharedPreferences.Editor editor = getReactApplicationContext().getSharedPreferences("RadarSDK", Context.MODE_PRIVATE).edit();
|
|
98
98
|
editor.putString("x_platform_sdk_type", "ReactNative");
|
|
99
|
-
editor.putString("x_platform_sdk_version", "3.20.
|
|
99
|
+
editor.putString("x_platform_sdk_version", "3.20.1-beta.1");
|
|
100
100
|
editor.apply();
|
|
101
101
|
if (fraud) {
|
|
102
102
|
Radar.initialize(getReactApplicationContext(), publishableKey, receiver, Radar.RadarLocationServicesProvider.GOOGLE, fraud);
|
package/ios/RNRadar.m
CHANGED
|
@@ -102,7 +102,7 @@ RCT_EXPORT_MODULE();
|
|
|
102
102
|
|
|
103
103
|
RCT_EXPORT_METHOD(initialize:(NSString *)publishableKey fraud:(BOOL)fraud) {
|
|
104
104
|
[[NSUserDefaults standardUserDefaults] setObject:@"ReactNative" forKey:@"radar-xPlatformSDKType"];
|
|
105
|
-
[[NSUserDefaults standardUserDefaults] setObject:@"3.20.
|
|
105
|
+
[[NSUserDefaults standardUserDefaults] setObject:@"3.20.1-beta.1" forKey:@"radar-xPlatformSDKVersion"];
|
|
106
106
|
[Radar initializeWithPublishableKey:publishableKey];
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -194,6 +194,10 @@ RCT_EXPORT_METHOD(requestPermissions:(BOOL)background resolve:(RCTPromiseResolve
|
|
|
194
194
|
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
|
|
195
195
|
if (background && status == kCLAuthorizationStatusAuthorizedWhenInUse) {
|
|
196
196
|
[locationManager requestAlwaysAuthorization];
|
|
197
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
198
|
+
selector:@selector(handleAppBecomingActive)
|
|
199
|
+
name:UIApplicationDidBecomeActiveNotification
|
|
200
|
+
object:nil];
|
|
197
201
|
} else if (status == kCLAuthorizationStatusNotDetermined) {
|
|
198
202
|
[locationManager requestWhenInUseAuthorization];
|
|
199
203
|
} else {
|
|
@@ -201,6 +205,15 @@ RCT_EXPORT_METHOD(requestPermissions:(BOOL)background resolve:(RCTPromiseResolve
|
|
|
201
205
|
}
|
|
202
206
|
}
|
|
203
207
|
|
|
208
|
+
- (void)handleAppBecomingActive
|
|
209
|
+
{
|
|
210
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
211
|
+
if (permissionsRequestResolver) {
|
|
212
|
+
[self getPermissionsStatusWithResolver:permissionsRequestResolver rejecter:nil];
|
|
213
|
+
permissionsRequestResolver = nil;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
204
217
|
RCT_EXPORT_METHOD(getLocation:(NSString *)desiredAccuracy resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
205
218
|
__block RCTPromiseResolveBlock resolver = resolve;
|
|
206
219
|
__block RCTPromiseRejectBlock rejecter = reject;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "React Native module for Radar, the leading geofencing and location tracking platform",
|
|
4
4
|
"homepage": "https://radar.com",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"version": "3.20.
|
|
6
|
+
"version": "3.20.1-beta.1",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"files": [
|
|
9
9
|
"/android",
|
package/plugin/build/types.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export interface RadarPluginProps {
|
|
|
5
5
|
iosNSLocationAlwaysAndWhenInUseUsageDescription?: string;
|
|
6
6
|
iosBackgroundMode?: boolean;
|
|
7
7
|
androidBackgroundPermission?: boolean;
|
|
8
|
-
|
|
8
|
+
androidForegroundService?: boolean;
|
|
9
|
+
androidActivityRecognition?: boolean;
|
|
9
10
|
addRadarSDKMotion?: boolean;
|
|
10
11
|
iosNSMotionUsageDescription?: string;
|
|
11
12
|
}
|
|
@@ -7,12 +7,8 @@ exports.withRadarAndroid = void 0;
|
|
|
7
7
|
const config_plugins_1 = require("expo/config-plugins");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const { addPermission } = config_plugins_1.AndroidConfig.Permissions;
|
|
11
10
|
const withRadarAndroid = (config, args) => {
|
|
12
|
-
config = (
|
|
13
|
-
config.modResults = await setCustomConfigAsync(config, config.modResults, args);
|
|
14
|
-
return config;
|
|
15
|
-
});
|
|
11
|
+
config = withAndroidPermissions(config, args);
|
|
16
12
|
config = (0, config_plugins_1.withDangerousMod)(config, [
|
|
17
13
|
"android",
|
|
18
14
|
async (config) => {
|
|
@@ -60,30 +56,19 @@ const withRadarAndroid = (config, args) => {
|
|
|
60
56
|
});
|
|
61
57
|
};
|
|
62
58
|
exports.withRadarAndroid = withRadarAndroid;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"android.permission.
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
if (!androidManifest.manifest["uses-permission"].some((e) => e["$"]["android:name"] === "android.permission.ACCESS_COARSE_LOCATION")) {
|
|
78
|
-
addPermission(androidManifest, "android.permission.ACCESS_COARSE_LOCATION");
|
|
79
|
-
}
|
|
80
|
-
if (!androidManifest.manifest["uses-permission"].some((e) => e["$"]["android:name"] === "android.permission.FOREGROUND_SERVICE")) {
|
|
81
|
-
addPermission(androidManifest, "android.permission.FOREGROUND_SERVICE");
|
|
82
|
-
}
|
|
83
|
-
if (!androidManifest.manifest["uses-permission"].some((e) => e["$"]["android:name"] === "android.permission.ACTIVITY_RECOGNITION")) {
|
|
84
|
-
addPermission(androidManifest, "android.permission.ACTIVITY_RECOGNITION");
|
|
85
|
-
}
|
|
86
|
-
return androidManifest;
|
|
59
|
+
function withAndroidPermissions(config, args) {
|
|
60
|
+
const isAndroidBackgroundLocationEnabled = !!args.androidBackgroundPermission;
|
|
61
|
+
const enableAndroidForegroundService = !!args.androidForegroundService;
|
|
62
|
+
const enableAndroidActivityRecognition = !!args.androidActivityRecognition;
|
|
63
|
+
return config_plugins_1.AndroidConfig.Permissions.withPermissions(config, [
|
|
64
|
+
isAndroidBackgroundLocationEnabled &&
|
|
65
|
+
"android.permission.ACCESS_BACKGROUND_LOCATION",
|
|
66
|
+
enableAndroidForegroundService && "android.permission.FOREGROUND_SERVICE",
|
|
67
|
+
enableAndroidForegroundService &&
|
|
68
|
+
"android.permission.FOREGROUND_SERVICE_LOCATION",
|
|
69
|
+
enableAndroidActivityRecognition &&
|
|
70
|
+
"android.permission.ACTIVITY_RECOGNITION",
|
|
71
|
+
].filter(Boolean));
|
|
87
72
|
}
|
|
88
73
|
function modifyAppBuildGradle(buildGradle, androidFraud) {
|
|
89
74
|
let hasLocationService = false;
|
|
@@ -96,7 +81,10 @@ function modifyAppBuildGradle(buildGradle, androidFraud) {
|
|
|
96
81
|
}
|
|
97
82
|
const pattern = /^dependencies {/m;
|
|
98
83
|
if (!buildGradle.match(pattern)) {
|
|
99
|
-
|
|
84
|
+
throw new Error(`Failed to find react.gradle script in android/app/build.gradle.
|
|
85
|
+
This is required for react-native-radar to function properly.
|
|
86
|
+
Please ensure your android/app/build.gradle includes the react.gradle script.
|
|
87
|
+
Current build.gradle content: ${buildGradle}`);
|
|
100
88
|
}
|
|
101
89
|
let replacementString = "\n\n" +
|
|
102
90
|
(!hasLocationService
|