react-native-radar 3.16.0 → 3.18.0

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,7 @@ android {
18
18
  minSdkVersion 16
19
19
  targetSdkVersion 31
20
20
  versionCode 1
21
- versionName '3.15.0'
21
+ versionName '3.18.0'
22
22
  }
23
23
  lintOptions {
24
24
  abortOnError false
@@ -45,6 +45,6 @@ repositories {
45
45
 
46
46
  dependencies {
47
47
  api 'com.facebook.react:react-native:+'
48
- api 'io.radar:sdk:3.16.2'
48
+ api 'io.radar:sdk:3.18.0'
49
49
  }
50
50
 
@@ -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.15.0");
99
+ editor.putString("x_platform_sdk_version", "3.18.0");
100
100
  editor.apply();
101
101
  if (fraud) {
102
102
  Radar.initialize(getReactApplicationContext(), publishableKey, receiver, Radar.RadarLocationServicesProvider.GOOGLE, fraud);
@@ -971,19 +971,31 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
971
971
  return;
972
972
  }
973
973
 
974
- if (!optionsMap.hasKey("query") || !optionsMap.hasKey("near")) {
974
+ if (!optionsMap.hasKey("query")) {
975
975
  promise.reject(Radar.RadarStatus.ERROR_BAD_REQUEST.toString(), Radar.RadarStatus.ERROR_BAD_REQUEST.toString());
976
976
 
977
977
  return;
978
978
  }
979
979
 
980
980
  String query = optionsMap.getString("query");
981
- ReadableMap nearMap = optionsMap.getMap("near");
982
- double latitude = nearMap.getDouble("latitude");
983
- double longitude = nearMap.getDouble("longitude");
984
- Location near = new Location("RNRadarModule");
985
- near.setLatitude(latitude);
986
- near.setLongitude(longitude);
981
+ Location near = null;
982
+
983
+ if (optionsMap.hasKey("near")) {
984
+ ReadableMap nearMap = optionsMap.getMap("near");
985
+ if (nearMap != null && nearMap.hasKey("latitude") && nearMap.hasKey("longitude")) {
986
+ try {
987
+ double latitude = nearMap.getDouble("latitude");
988
+ double longitude = nearMap.getDouble("longitude");
989
+ near = new Location("RNRadarModule");
990
+ near.setLatitude(latitude);
991
+ near.setLongitude(longitude);
992
+ } catch (Exception e) {
993
+ promise.reject(Radar.RadarStatus.ERROR_BAD_REQUEST.toString(), "Invalid near coordinates");
994
+ return;
995
+ }
996
+ }
997
+ }
998
+
987
999
  int limit = optionsMap.hasKey("limit") ? optionsMap.getInt("limit") : 10;
988
1000
  String country = optionsMap.hasKey("countryCode") ? optionsMap.getString("countryCode") : optionsMap.hasKey("country") ? optionsMap.getString("country") : null;
989
1001
  String[] layers = optionsMap.hasKey("layers") ? RNRadarUtils.stringArrayForArray(optionsMap.getArray("layers")) : null;
@@ -1 +1 @@
1
- github "radarlabs/radar-sdk-ios" "3.16.0"
1
+ github "radarlabs/radar-sdk-ios" "3.18.0"
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.15.0" forKey:@"radar-xPlatformSDKVersion"];
105
+ [[NSUserDefaults standardUserDefaults] setObject:@"3.18.0" forKey:@"radar-xPlatformSDKVersion"];
106
106
  [Radar initializeWithPublishableKey:publishableKey];
107
107
  }
108
108
 
@@ -818,10 +818,18 @@ RCT_EXPORT_METHOD(autocomplete:(NSDictionary *)optionsDict resolve:(RCTPromiseRe
818
818
  NSDictionary *nearDict = optionsDict[@"near"];
819
819
  CLLocation *near = nil;
820
820
  if (nearDict && [nearDict isKindOfClass:[NSDictionary class]]) {
821
- double latitude = [RCTConvert double:nearDict[@"latitude"]];
822
- double longitude = [RCTConvert double:nearDict[@"longitude"]];
823
- NSDate *timestamp = [NSDate new];
824
- near = [[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude) altitude:-1 horizontalAccuracy:5 verticalAccuracy:-1 timestamp:timestamp];
821
+ id latitudeObj = nearDict[@"latitude"];
822
+ id longitudeObj = nearDict[@"longitude"];
823
+
824
+ if (latitudeObj && longitudeObj &&
825
+ [latitudeObj isKindOfClass:[NSNumber class]] &&
826
+ [longitudeObj isKindOfClass:[NSNumber class]]) {
827
+
828
+ double latitude = [RCTConvert double:latitudeObj];
829
+ double longitude = [RCTConvert double:longitudeObj];
830
+ NSDate *timestamp = [NSDate new];
831
+ near = [[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude) altitude:-1 horizontalAccuracy:5 verticalAccuracy:-1 timestamp:timestamp];
832
+ }
825
833
  }
826
834
 
827
835
 
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.16.0",
6
+ "version": "3.18.0",
7
7
  "main": "dist/index.js",
8
8
  "files": [
9
9
  "/android",
@@ -6,4 +6,6 @@ export interface RadarPluginProps {
6
6
  iosBackgroundMode?: boolean;
7
7
  androidBackgroundPermission?: boolean;
8
8
  androidFineLocationPermission?: boolean;
9
+ addRadarSDKMotion?: boolean;
10
+ iosNSMotionUsageDescription?: string;
9
11
  }
@@ -80,6 +80,9 @@ async function setCustomConfigAsync(config, androidManifest, args) {
80
80
  if (!androidManifest.manifest["uses-permission"].some((e) => e["$"]["android:name"] === "android.permission.FOREGROUND_SERVICE")) {
81
81
  addPermission(androidManifest, "android.permission.FOREGROUND_SERVICE");
82
82
  }
83
+ if (!androidManifest.manifest["uses-permission"].some((e) => e["$"]["android:name"] === "android.permission.ACTIVITY_RECOGNITION")) {
84
+ addPermission(androidManifest, "android.permission.ACTIVITY_RECOGNITION");
85
+ }
83
86
  return androidManifest;
84
87
  }
85
88
  function modifyAppBuildGradle(buildGradle, androidFraud) {
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.withRadarIOS = void 0;
4
7
  const config_plugins_1 = require("expo/config-plugins");
8
+ const promises_1 = __importDefault(require("fs/promises"));
9
+ const path_1 = __importDefault(require("path"));
5
10
  const withRadarIOS = (config, args) => {
6
- return (0, config_plugins_1.withInfoPlist)(config, (config) => {
11
+ config = (0, config_plugins_1.withInfoPlist)(config, (config) => {
7
12
  config.modResults.NSLocationWhenInUseUsageDescription =
8
13
  args.iosNSLocationWhenInUseUsageDescription ??
9
14
  "This app uses the location service to provide location-based services.";
@@ -32,7 +37,39 @@ const withRadarIOS = (config, args) => {
32
37
  },
33
38
  };
34
39
  }
40
+ if (args.addRadarSDKMotion) {
41
+ config.modResults.NSMotionUsageDescription =
42
+ args.iosNSMotionUsageDescription ??
43
+ "This app uses the motion service to provide motion-based services.";
44
+ }
35
45
  return config;
36
46
  });
47
+ if (args.addRadarSDKMotion) {
48
+ config = (0, config_plugins_1.withDangerousMod)(config, [
49
+ 'ios',
50
+ async (config) => {
51
+ const filePath = path_1.default.join(config.modRequest.platformProjectRoot, 'Podfile');
52
+ const contents = await promises_1.default.readFile(filePath, 'utf-8');
53
+ // Check if the pod declaration already exists
54
+ if (contents.indexOf("pod 'RadarSDKMotion', '3.18.0'") === -1) {
55
+ // Find the target block
56
+ const targetRegex = /target '(\w+)' do/g;
57
+ const match = targetRegex.exec(contents);
58
+ if (match) {
59
+ const targetStartIndex = match.index;
60
+ const targetEndIndex = contents.indexOf('end', targetStartIndex) + 3;
61
+ // Insert the pod declaration within the target block
62
+ const targetBlock = contents.substring(targetStartIndex, targetEndIndex);
63
+ const updatedTargetBlock = targetBlock.replace(/(target '(\w+)' do)/, `$1\n pod 'RadarSDKMotion', '3.18.0'`);
64
+ const newContents = contents.replace(targetBlock, updatedTargetBlock);
65
+ // Write the updated contents back to the Podfile
66
+ await promises_1.default.writeFile(filePath, newContents);
67
+ }
68
+ }
69
+ return config;
70
+ },
71
+ ]);
72
+ }
73
+ return config;
37
74
  };
38
75
  exports.withRadarIOS = withRadarIOS;
@@ -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.16.0"
18
+ s.dependency "RadarSDK", "~> 3.18.0"
19
19
  end