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.
- package/android/build.gradle +2 -2
- package/android/src/main/java/io/radar/react/RNRadarModule.java +20 -8
- package/ios/Cartfile.resolved +1 -1
- package/ios/RNRadar.m +13 -5
- package/package.json +1 -1
- package/plugin/build/types.d.ts +2 -0
- package/plugin/build/withRadarAndroid.js +3 -0
- package/plugin/build/withRadarIOS.js +38 -1
- package/react-native-radar.podspec +1 -1
package/android/build.gradle
CHANGED
|
@@ -18,7 +18,7 @@ android {
|
|
|
18
18
|
minSdkVersion 16
|
|
19
19
|
targetSdkVersion 31
|
|
20
20
|
versionCode 1
|
|
21
|
-
versionName '3.
|
|
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.
|
|
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.
|
|
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")
|
|
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
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
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;
|
package/ios/Cartfile.resolved
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
github "radarlabs/radar-sdk-ios" "3.
|
|
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.
|
|
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
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
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
package/plugin/build/types.d.ts
CHANGED
|
@@ -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
|
-
|
|
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;
|