react-native-radar 3.20.1-beta.5 → 3.20.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.
@@ -18,7 +18,8 @@ android {
18
18
  minSdkVersion 16
19
19
  targetSdkVersion 31
20
20
  versionCode 1
21
- versionName '3.20.1-beta.5'
21
+ versionName '3.20.1'
22
+ consumerProguardFiles 'proguard-rules.pro'
22
23
  }
23
24
  lintOptions {
24
25
  abortOnError false
@@ -45,6 +46,6 @@ repositories {
45
46
 
46
47
  dependencies {
47
48
  api 'com.facebook.react:react-native:+'
48
- api 'io.radar:sdk:3.21.3-beta.4'
49
+ api 'io.radar:sdk:3.21.2'
49
50
  }
50
51
 
@@ -0,0 +1,4 @@
1
+ -dontwarn com.huawei.**
2
+
3
+ -dontwarn com.google.android.play.integrity.**
4
+ -dontwarn com.google.android.play.core.integrity.**
@@ -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.1-beta.5");
99
+ editor.putString("x_platform_sdk_version", "3.20.1");
100
100
  editor.apply();
101
101
  if (fraud) {
102
102
  Radar.initialize(getReactApplicationContext(), publishableKey, receiver, Radar.RadarLocationServicesProvider.GOOGLE, fraud);
@@ -255,7 +255,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
255
255
  if (activity != null) {
256
256
  if (Build.VERSION.SDK_INT >= 23) {
257
257
  if (background && Build.VERSION.SDK_INT >= 29) {
258
- activity.requestPermissions(new String[] { Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION }, PERMISSIONS_REQUEST_CODE, this);
258
+ activity.requestPermissions(new String[] { Manifest.permission.ACCESS_BACKGROUND_LOCATION }, PERMISSIONS_REQUEST_CODE, this);
259
259
  } else {
260
260
  activity.requestPermissions(new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, PERMISSIONS_REQUEST_CODE, this);
261
261
  }
@@ -1 +1 @@
1
- github "radarlabs/radar-sdk-ios" "3.21.1"
1
+ github "radarlabs/radar-sdk-ios" "3.21.2"
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.1-beta.5" forKey:@"radar-xPlatformSDKVersion"];
105
+ [[NSUserDefaults standardUserDefaults] setObject:@"3.20.1" forKey:@"radar-xPlatformSDKVersion"];
106
106
  [Radar initializeWithPublishableKey:publishableKey];
107
107
  }
108
108
 
@@ -189,15 +189,30 @@ RCT_REMAP_METHOD(getPermissionsStatus, getPermissionsStatusWithResolver:(RCTProm
189
189
  }
190
190
 
191
191
  RCT_EXPORT_METHOD(requestPermissions:(BOOL)background resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
192
- permissionsRequestResolver = resolve;
193
-
192
+
194
193
  CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
195
194
  if (background && status == kCLAuthorizationStatusAuthorizedWhenInUse) {
195
+ permissionsRequestResolver = resolve;
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) {
202
+ permissionsRequestResolver = resolve;
198
203
  [locationManager requestWhenInUseAuthorization];
199
204
  } else {
200
205
  [self getPermissionsStatusWithResolver:resolve rejecter:reject];
206
+ permissionsRequestResolver = nil;
207
+ }
208
+ }
209
+
210
+ - (void)handleAppBecomingActive
211
+ {
212
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
213
+ if (permissionsRequestResolver) {
214
+ [self getPermissionsStatusWithResolver:permissionsRequestResolver rejecter:nil];
215
+ permissionsRequestResolver = nil;
201
216
  }
202
217
  }
203
218
 
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.1-beta.5",
6
+ "version": "3.20.1",
7
7
  "main": "dist/index.js",
8
8
  "files": [
9
9
  "/android",
@@ -5,7 +5,8 @@ export interface RadarPluginProps {
5
5
  iosNSLocationAlwaysAndWhenInUseUsageDescription?: string;
6
6
  iosBackgroundMode?: boolean;
7
7
  androidBackgroundPermission?: boolean;
8
- androidFineLocationPermission?: boolean;
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 = (0, config_plugins_1.withAndroidManifest)(config, async (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
- async function setCustomConfigAsync(config, androidManifest, args) {
64
- if (!androidManifest.manifest["uses-permission"]) {
65
- androidManifest.manifest["uses-permission"] = [];
66
- }
67
- // Add permissions
68
- if (args.androidFineLocationPermission &&
69
- !androidManifest.manifest["uses-permission"].some((e) => e["$"]["android:name"] === "android.permission.ACCESS_FINE_LOCATION")) {
70
- addPermission(androidManifest, "android.permission.ACCESS_FINE_LOCATION");
71
- }
72
- if (args.androidBackgroundPermission &&
73
- !androidManifest.manifest["uses-permission"].some((e) => e["$"]["android:name"] ===
74
- "android.permission.ACCESS_BACKGROUND_LOCATION")) {
75
- addPermission(androidManifest, "android.permission.ACCESS_BACKGROUND_LOCATION");
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
- config_plugins_1.WarningAggregator.addWarningAndroid("react-native-radar", "Could not find react.gradle script in android/app/build.gradle.");
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
@@ -51,7 +51,7 @@ const withRadarIOS = (config, args) => {
51
51
  const filePath = path_1.default.join(config.modRequest.platformProjectRoot, 'Podfile');
52
52
  const contents = await promises_1.default.readFile(filePath, 'utf-8');
53
53
  // Check if the pod declaration already exists
54
- if (contents.indexOf("pod 'RadarSDKMotion', '3.21.1'") === -1) {
54
+ if (contents.indexOf("pod 'RadarSDKMotion', '3.21.2'") === -1) {
55
55
  // Find the target block
56
56
  const targetRegex = /target '(\w+)' do/g;
57
57
  const match = targetRegex.exec(contents);
@@ -60,6 +60,7 @@ const withRadarIOS = (config, args) => {
60
60
  const targetEndIndex = contents.indexOf('end', targetStartIndex) + 3;
61
61
  // Insert the pod declaration within the target block
62
62
  const targetBlock = contents.substring(targetStartIndex, targetEndIndex);
63
+ // Just for this version of the SDK, we will be using 3.21.1 of the SDKMotion pod. There is no difference between the source code of 3.21.2 and 3.21.1 for RadarSDKMotion.
63
64
  const updatedTargetBlock = targetBlock.replace(/(target '(\w+)' do)/, `$1\n pod 'RadarSDKMotion', '3.21.1'`);
64
65
  const newContents = contents.replace(targetBlock, updatedTargetBlock);
65
66
  // Write the updated contents back to the Podfile
@@ -15,5 +15,5 @@ Pod::Spec.new do |s|
15
15
  s.platform = :ios, "10.0"
16
16
 
17
17
  s.dependency "React"
18
- s.dependency "RadarSDK", "~> 3.21.1"
18
+ s.dependency "RadarSDK", "~> 3.21.2"
19
19
  end