Skip to content

Commit

Permalink
should build and fail
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiCheng-Lu committed Nov 12, 2024
1 parent 9260ead commit 2509c79
Show file tree
Hide file tree
Showing 11 changed files with 457 additions and 117 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ jobs:
name: Install Ninja
command: sudo apt-get update && sudo apt-get install -y ninja-build
- run: chown -R $USER:$USER android
- run: cd android && ./gradlew
- run: cd android && ./gradlew assembleDebug

ios:
macos:
xcode: "15.3.0"
Expand All @@ -70,7 +71,7 @@ jobs:
command: npm run install-radar-rebuild-dirty
- run: cd ios && pod update RadarSDK && pod install
- run: xcodebuild -workspace ios/Example.xcworkspace -scheme Example -sdk iphonesimulator


workflows:
version: 2
Expand Down
40 changes: 28 additions & 12 deletions android/src/main/java/io/radar/react/RNRadarModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -1115,21 +1115,37 @@ public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarAddress

@ReactMethod
public void validateAddress(ReadableMap addressMap, final Promise promise) {
RadarAddress address = RadarAddress.fromJson(RNRadarUtils.jsonForMap(addressMap));
Radar.validateAddress(address, new RadarValidateAddressCallback {
if (promise == null) {
return;
}

RadarAddress address;
try {
address = RadarAddress.fromJson(RNRadarUtils.jsonForMap(addressMap));
} catch (JSONException e) {
promise.reject(Radar.RadarStatus.ERROR_BAD_REQUEST.toString(), Radar.RadarStatus.ERROR_BAD_REQUEST.toString());
return;
}
Radar.validateAddress(address, new Radar.RadarValidateAddressCallback() {
@Override
onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarAddress address, @Nullable RadarAddressVerificationStatus verificationStatus) {
if (status == Radar.RadarStatus.SUCCESS && ) {
map.putString("status", status.toString());
if (address != null) {
map.putMap("address", RNRadarUtils.mapForJson(address.toJson()));
}
if (verificationStatus != null) {
map.putString("verificationStatus", verificationStatus.toString());
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarAddress address, @Nullable Radar.RadarAddressVerificationStatus verificationStatus) {
if (status == Radar.RadarStatus.SUCCESS) {
try {
WritableMap map = Arguments.createMap();
map.putString("status", status.toString());
if (address != null) {
map.putMap("address", RNRadarUtils.mapForJson(address.toJson()));
}
if (verificationStatus != null) {
map.putString("verificationStatus", verificationStatus.toString());
}
promise.resolve(map);
} catch (JSONException e) {
Log.e(TAG, "JSONException", e);
promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString());
}
promise.resolve(map);
} else {
promise.reject(status.toString, status.toString());
promise.reject(status.toString(), status.toString());
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/java/io/radar/react/RNRadarReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void onEventsReceived(@NonNull Context context, @NonNull RadarEvent[] eve
WritableMap map = Arguments.createMap();
map.putArray("events", RNRadarUtils.arrayForJson(RadarEvent.toJson(events)));
if (user != null) {
map.putMap("user", RNRadarUtils.mapForJson(user.toJson()));
map.putMap("user", RNRadarUtils.mapForoJson()));
}

sendEvent("events", map);
Expand Down
74 changes: 44 additions & 30 deletions example/App.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
import React, { useState, useEffect } from "react";
import { StyleSheet, Text, View, ScrollView } from "react-native";
import Radar, { Map, Autocomplete } from "react-native-radar";
import { StyleSheet, Text, View, ScrollView, Platform } from "react-native";
import Radar, { Map, Autocomplete, RadarClientLocationUpdate, RadarLocationUpdate, RadarEventUpdate } from "react-native-radar";
import MapLibreGL from "@maplibre/maplibre-react-native";
import ExampleButton from "./components/exampleButton";

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

const stringify = (obj) => JSON.stringify(obj, null, 2);
const stringify = (obj: any) => JSON.stringify(obj, null, 2);

Radar.on("events", (result) => {
Radar.on("events", (result: RadarEventUpdate) => {
console.log("events:", stringify(result));
});

Radar.on("location", (result) => {
Radar.on("location", (result: RadarLocationUpdate) => {
console.log("location:", stringify(result));
});

Radar.on("clientLocation", (result) => {
Radar.on("clientLocation", (result: RadarClientLocationUpdate) => {
console.log("clientLocation:", stringify(result));
});

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

Radar.on("log", (result) => {
Radar.on("log", (result: string) => {
console.log("log:", stringify(result));
});

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

const handlePopulateText = (displayText) => {
const handlePopulateText = (displayText: string) => {
setDisplayText(displayText);
};

const stringify = (obj) => JSON.stringify(obj, null, 2);
Radar.initialize("prj_test_pk_0000000000000000000000000000000000000000", true);

useEffect(() => {
Radar.setLogLevel("info");
Radar.setLogLevel("debug");

Radar.setUserId("foo");

Expand All @@ -57,24 +55,28 @@ export default function App() {
return (
<View style={styles.container}>
{/* The current version of MapLibre does not support the new react native architecture */}
{/* <View style={{ width: "100%", height: "40%" }}>
<Map />
</View> */}
<View style={{ width: "100%", height: "10%" }}>
<Autocomplete
options={{
near: {
latitude: 40.7342,
longitude: -73.9911,
},
}}
/>
</View>
<View style={{ width: "100%", height: "50%" }}>
<ScrollView>
{Platform.OS !== "web" &&
<>
<View style={{ width: "100%", height: "40%" }}>
<Map />
</View>
<View style={{ width: "100%", height: "10%" }}>
<Autocomplete
options={{
near: {
latitude: 40.7342,
longitude: -73.9911,
},
}}
/>
</View>
</>
}
<View style={{ width: "100%", height: Platform.OS !== "web" ? "50%" : "100%" }}>
<ScrollView style={{ height: "25%" }}>
<Text style={styles.displayText}>{displayText}</Text>
</ScrollView>
<ScrollView>
<ScrollView style={{ height: "75%" }}>
<ExampleButton
title="getUser"
onPress={() => {
Expand Down Expand Up @@ -186,7 +188,7 @@ export default function App() {
.then((result) => {
handlePopulateText(
"trackOnce manual with location accuracy::" +
stringify(result)
stringify(result)
);
})
.catch((err) => {
Expand All @@ -197,7 +199,7 @@ export default function App() {
}}
/>
<ExampleButton
title="trackOnce manual with beacons:"
title="trackOnce manual with beacons"
onPress={() => {
Radar.trackOnce({
desiredAccuracy: "medium",
Expand Down Expand Up @@ -561,6 +563,15 @@ export default function App() {
});
}}
/>

<ExampleButton
title="version"
onPress={() => {
Radar.nativeSdkVersion().then((nativeVersion) => {
handlePopulateText(`sdk: ${Radar.rnSdkVersion()}, native: ${nativeVersion}`);
})
}}
/>
</ScrollView>
</View>
</View>
Expand All @@ -574,4 +585,7 @@ const styles = StyleSheet.create({
alignItems: "center",
justifyContent: "center",
},
displayText: {
flex: 1
}
});
Loading

0 comments on commit 2509c79

Please sign in to comment.