Skip to content

Commit 2509c79

Browse files
committed
should build and fail
1 parent 9260ead commit 2509c79

File tree

11 files changed

+457
-117
lines changed

11 files changed

+457
-117
lines changed

.circleci/config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ jobs:
5454
name: Install Ninja
5555
command: sudo apt-get update && sudo apt-get install -y ninja-build
5656
- run: chown -R $USER:$USER android
57-
- run: cd android && ./gradlew
57+
- run: cd android && ./gradlew assembleDebug
58+
5859
ios:
5960
macos:
6061
xcode: "15.3.0"
@@ -70,7 +71,7 @@ jobs:
7071
command: npm run install-radar-rebuild-dirty
7172
- run: cd ios && pod update RadarSDK && pod install
7273
- run: xcodebuild -workspace ios/Example.xcworkspace -scheme Example -sdk iphonesimulator
73-
74+
7475

7576
workflows:
7677
version: 2

android/src/main/java/io/radar/react/RNRadarModule.java

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,21 +1115,37 @@ public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarAddress
11151115

11161116
@ReactMethod
11171117
public void validateAddress(ReadableMap addressMap, final Promise promise) {
1118-
RadarAddress address = RadarAddress.fromJson(RNRadarUtils.jsonForMap(addressMap));
1119-
Radar.validateAddress(address, new RadarValidateAddressCallback {
1118+
if (promise == null) {
1119+
return;
1120+
}
1121+
1122+
RadarAddress address;
1123+
try {
1124+
address = RadarAddress.fromJson(RNRadarUtils.jsonForMap(addressMap));
1125+
} catch (JSONException e) {
1126+
promise.reject(Radar.RadarStatus.ERROR_BAD_REQUEST.toString(), Radar.RadarStatus.ERROR_BAD_REQUEST.toString());
1127+
return;
1128+
}
1129+
Radar.validateAddress(address, new Radar.RadarValidateAddressCallback() {
11201130
@Override
1121-
onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarAddress address, @Nullable RadarAddressVerificationStatus verificationStatus) {
1122-
if (status == Radar.RadarStatus.SUCCESS && ) {
1123-
map.putString("status", status.toString());
1124-
if (address != null) {
1125-
map.putMap("address", RNRadarUtils.mapForJson(address.toJson()));
1126-
}
1127-
if (verificationStatus != null) {
1128-
map.putString("verificationStatus", verificationStatus.toString());
1131+
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarAddress address, @Nullable Radar.RadarAddressVerificationStatus verificationStatus) {
1132+
if (status == Radar.RadarStatus.SUCCESS) {
1133+
try {
1134+
WritableMap map = Arguments.createMap();
1135+
map.putString("status", status.toString());
1136+
if (address != null) {
1137+
map.putMap("address", RNRadarUtils.mapForJson(address.toJson()));
1138+
}
1139+
if (verificationStatus != null) {
1140+
map.putString("verificationStatus", verificationStatus.toString());
1141+
}
1142+
promise.resolve(map);
1143+
} catch (JSONException e) {
1144+
Log.e(TAG, "JSONException", e);
1145+
promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString());
11291146
}
1130-
promise.resolve(map);
11311147
} else {
1132-
promise.reject(status.toString, status.toString());
1148+
promise.reject(status.toString(), status.toString());
11331149
}
11341150
}
11351151
});

android/src/main/java/io/radar/react/RNRadarReceiver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void onEventsReceived(@NonNull Context context, @NonNull RadarEvent[] eve
4545
WritableMap map = Arguments.createMap();
4646
map.putArray("events", RNRadarUtils.arrayForJson(RadarEvent.toJson(events)));
4747
if (user != null) {
48-
map.putMap("user", RNRadarUtils.mapForJson(user.toJson()));
48+
map.putMap("user", RNRadarUtils.mapForoJson()));
4949
}
5050

5151
sendEvent("events", map);

example/App.tsx

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,45 @@
11
import React, { useState, useEffect } from "react";
2-
import { StyleSheet, Text, View, ScrollView } from "react-native";
3-
import Radar, { Map, Autocomplete } from "react-native-radar";
2+
import { StyleSheet, Text, View, ScrollView, Platform } from "react-native";
3+
import Radar, { Map, Autocomplete, RadarClientLocationUpdate, RadarLocationUpdate, RadarEventUpdate } from "react-native-radar";
44
import MapLibreGL from "@maplibre/maplibre-react-native";
55
import ExampleButton from "./components/exampleButton";
66

77
// The current version of MapLibre does not support the new react native architecture
88
// MapLibreGL.setAccessToken(null);
99

10-
const stringify = (obj) => JSON.stringify(obj, null, 2);
10+
const stringify = (obj: any) => JSON.stringify(obj, null, 2);
1111

12-
Radar.on("events", (result) => {
12+
Radar.on("events", (result: RadarEventUpdate) => {
1313
console.log("events:", stringify(result));
1414
});
1515

16-
Radar.on("location", (result) => {
16+
Radar.on("location", (result: RadarLocationUpdate) => {
1717
console.log("location:", stringify(result));
1818
});
1919

20-
Radar.on("clientLocation", (result) => {
20+
Radar.on("clientLocation", (result: RadarClientLocationUpdate) => {
2121
console.log("clientLocation:", stringify(result));
2222
});
2323

2424
Radar.on("error", (err) => {
2525
console.log("error:", stringify(err));
2626
});
2727

28-
Radar.on("log", (result) => {
28+
Radar.on("log", (result: string) => {
2929
console.log("log:", stringify(result));
3030
});
3131

3232
export default function App() {
3333
// add in your test code here!
3434
const [displayText, setDisplayText] = useState("");
3535

36-
const handlePopulateText = (displayText) => {
36+
const handlePopulateText = (displayText: string) => {
3737
setDisplayText(displayText);
3838
};
39-
40-
const stringify = (obj) => JSON.stringify(obj, null, 2);
4139
Radar.initialize("prj_test_pk_0000000000000000000000000000000000000000", true);
42-
40+
4341
useEffect(() => {
44-
Radar.setLogLevel("info");
42+
Radar.setLogLevel("debug");
4543

4644
Radar.setUserId("foo");
4745

@@ -57,24 +55,28 @@ export default function App() {
5755
return (
5856
<View style={styles.container}>
5957
{/* The current version of MapLibre does not support the new react native architecture */}
60-
{/* <View style={{ width: "100%", height: "40%" }}>
61-
<Map />
62-
</View> */}
63-
<View style={{ width: "100%", height: "10%" }}>
64-
<Autocomplete
65-
options={{
66-
near: {
67-
latitude: 40.7342,
68-
longitude: -73.9911,
69-
},
70-
}}
71-
/>
72-
</View>
73-
<View style={{ width: "100%", height: "50%" }}>
74-
<ScrollView>
58+
{Platform.OS !== "web" &&
59+
<>
60+
<View style={{ width: "100%", height: "40%" }}>
61+
<Map />
62+
</View>
63+
<View style={{ width: "100%", height: "10%" }}>
64+
<Autocomplete
65+
options={{
66+
near: {
67+
latitude: 40.7342,
68+
longitude: -73.9911,
69+
},
70+
}}
71+
/>
72+
</View>
73+
</>
74+
}
75+
<View style={{ width: "100%", height: Platform.OS !== "web" ? "50%" : "100%" }}>
76+
<ScrollView style={{ height: "25%" }}>
7577
<Text style={styles.displayText}>{displayText}</Text>
7678
</ScrollView>
77-
<ScrollView>
79+
<ScrollView style={{ height: "75%" }}>
7880
<ExampleButton
7981
title="getUser"
8082
onPress={() => {
@@ -186,7 +188,7 @@ export default function App() {
186188
.then((result) => {
187189
handlePopulateText(
188190
"trackOnce manual with location accuracy::" +
189-
stringify(result)
191+
stringify(result)
190192
);
191193
})
192194
.catch((err) => {
@@ -197,7 +199,7 @@ export default function App() {
197199
}}
198200
/>
199201
<ExampleButton
200-
title="trackOnce manual with beacons:"
202+
title="trackOnce manual with beacons"
201203
onPress={() => {
202204
Radar.trackOnce({
203205
desiredAccuracy: "medium",
@@ -561,6 +563,15 @@ export default function App() {
561563
});
562564
}}
563565
/>
566+
567+
<ExampleButton
568+
title="version"
569+
onPress={() => {
570+
Radar.nativeSdkVersion().then((nativeVersion) => {
571+
handlePopulateText(`sdk: ${Radar.rnSdkVersion()}, native: ${nativeVersion}`);
572+
})
573+
}}
574+
/>
564575
</ScrollView>
565576
</View>
566577
</View>
@@ -574,4 +585,7 @@ const styles = StyleSheet.create({
574585
alignItems: "center",
575586
justifyContent: "center",
576587
},
588+
displayText: {
589+
flex: 1
590+
}
577591
});

0 commit comments

Comments
 (0)