Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added new method MapViewRef.setShareLiveLocationSession to set the session identifier of the Share Live Location Session the MapView should display. When enabled in the [Map Viewer Configuration Settings](https://situm.com/docs/map-viewer-configuration-settings/), Share Live Location functionality allows a user to share their real-time location with another user.
- Added the internal functionality that allows to share the user location (a Share Live Location Session) with another user.
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ PODS:
- React-logger (= 0.79.1)
- React-perflogger (= 0.79.1)
- React-utils (= 0.79.1)
- ReactNativeSitumPlugin (3.17.2):
- ReactNativeSitumPlugin (3.18.2):
- DoubleConversion
- glog
- hermes-engine
Expand All @@ -1705,7 +1705,7 @@ PODS:
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- SitumSDK (= 3.34.10)
- SitumSDK (= 3.35.0)
- Yoga
- RNScreens (4.11.1):
- DoubleConversion
Expand Down Expand Up @@ -1756,7 +1756,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- SitumSDK (3.34.10):
- SitumSDK (3.35.0):
- Protobuf (~> 3.18)
- SSZipArchive (~> 2.4)
- SocketRocket (0.7.1)
Expand Down Expand Up @@ -2075,10 +2075,10 @@ SPEC CHECKSUMS:
ReactAppDependencyProvider: f3426eaf6dabae0baec543cd7bac588b6f59210c
ReactCodegen: 3288d61658273d72fbd348a74b59710b9790615f
ReactCommon: 9f975582dc535de1de110bdb46d4553140a77541
ReactNativeSitumPlugin: c0f365b20d0368473061abf31fa649417a98a647
ReactNativeSitumPlugin: 62552d7f3e5b0ac826ebbfe920ef40365235863f
RNScreens: 3dbce61975990754e4eadd42e9155d327c3445e7
RNVectorIcons: ae8e1b95f3468a360896c6242d61885efcc64241
SitumSDK: de58cad6f48b83451f820452e57f1586ab8b9d2a
SitumSDK: 87645bb5da3348b0da02b440ca40d3c244684692
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
Yoga: d15f5aa644c466e917569ac43b19cbf17975239a
Expand Down
4 changes: 2 additions & 2 deletions example/src/navigation/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
export type RootTabsParamsList = {
Home: undefined;
Wayfinding: {
poiIdentifier: string;
action: "select" | "navigate";
elementIdentifier: string;
action: "select" | "navigate" | "shareLiveLocation";
};
};

Expand Down
18 changes: 16 additions & 2 deletions example/src/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Alert, ScrollView, StyleSheet } from "react-native";
import { FetchResourcesCard } from "./cards/FetchResourcesCard";
import { SITUM_BUILDING_ID } from "../situm";
import { MapInteractionCard } from "./cards/MapInteractionCard";
import { ShareLiveLocationCard } from "./cards/ShareLiveLocationCard";
import { useNavigation } from "@react-navigation/native";

export const HomeScreen = () => {
Expand Down Expand Up @@ -72,7 +73,7 @@ export const HomeScreen = () => {

const selectPoi = (identifier: string) => {
navigation.navigate("Wayfinding", {
poiIdentifier: identifier,
elementIdentifier: identifier,
action: "select",
});
};
Expand All @@ -86,11 +87,21 @@ export const HomeScreen = () => {
return;
}
navigation.navigate("Wayfinding", {
poiIdentifier: identifier,
elementIdentifier: identifier,
action: "navigate",
});
};

// ////////////////////////////////////////////////////////////////////////
// SHARE LIVE LOCATION:
// ////////////////////////////////////////////////////////////////////////
const setShareLiveLocationSession = (identifier: string) => {
navigation.navigate("Wayfinding", {
elementIdentifier: identifier,
action: "shareLiveLocation",
});
};

// ////////////////////////////////////////////////////////////////////////
// FETCH RESOURCES:
// ////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -186,6 +197,9 @@ export const HomeScreen = () => {
onSelectPoi={selectPoi}
onNavigateToPoi={navigateToPoi}
/>
<ShareLiveLocationCard
onSetShareLiveLocationSession={setShareLiveLocationSession}
/>
<FetchResourcesCard
onFetchBuildingInfo={fetchBuildingInfo}
onFetchPois={fetchPois}
Expand Down
24 changes: 15 additions & 9 deletions example/src/screens/WayfindingScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,42 +77,48 @@ export const WayfindingScreen: React.FC = () => {
// ACTIONS:
// ////////////////////////////////////////////////////////////////////////

// Get the POI identifier from react-navigation route params.
// Get the Element identifier from react-navigation route params.
const navigation = useNavigation();
const route = useRoute<RouteProp<RootTabsParamsList, "Wayfinding">>();
const { poiIdentifier, action } = route.params || {};
const { elementIdentifier, action } = route.params || {};

useEffect(() => {
// The MapView must be loaded to perform actions.
if (!mapViewLoaded) return;
if (!poiIdentifier || !action) return;
if (!elementIdentifier || !action) return;

if (action === "select") {
selectPoi(poiIdentifier);
selectPoi(elementIdentifier);
} else if (action === "navigate") {
navigateToPoi(poiIdentifier);
navigateToPoi(elementIdentifier);
} else if (action === "shareLiveLocation") {
setShareLiveLocationSession(elementIdentifier);
}

// Reset params to make the useEffect execute even with the same values.
navigation.setParams({
poiIdentifier: undefined,
elementIdentifier: undefined,
action: undefined,
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [poiIdentifier, action, mapViewLoaded]);
}, [elementIdentifier, action, mapViewLoaded]);

// eslint-disable-next-line @typescript-eslint/no-shadow
const selectPoi = (poiIdentifier: string) => {
controller?.selectPoi(Number(poiIdentifier));
};

// eslint-disable-next-line @typescript-eslint/no-shadow
const navigateToPoi = (poiIdentifier: string) => {
controller?.navigateToPoi({
identifier: Number(poiIdentifier),
});
};

const setShareLiveLocationSession = (sessionIdentifier: string) => {
controller?.setShareLiveLocationSession({
identifier: sessionIdentifier,
});
};

return (
<PaperProvider>
<SafeAreaView edges={["top"]} style={{ ...styles.container }}>
Expand Down
67 changes: 67 additions & 0 deletions example/src/screens/cards/ShareLiveLocationCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, { useState } from "react";
import { Button, View, StyleSheet, Platform, TextInput } from "react-native";
import { Card, Icon, Text } from "react-native-paper";
import { Colors, SharedStyles } from "../../SharedStyles";

const CardTitleIcon = () => <Icon source="share-social-outline" size={20} />;

interface ShareLiveLocationCardProps {
onSetShareLiveLocationSession: (identifier: string) => void;
}

export const ShareLiveLocationCard: React.FC<ShareLiveLocationCardProps> = ({
onSetShareLiveLocationSession,
}) => {
const [identifier, setIdentifier] = useState("");

return (
<Card style={SharedStyles.card}>
<Card.Title
title="Share Live Location"
left={CardTitleIcon}
titleStyle={SharedStyles.title}
/>

<Card.Content>
{/* Campo de texto */}
<TextInput
style={styles.input}
placeholder="Enter session identifier"
value={identifier}
onChangeText={setIdentifier}
/>

<View style={SharedStyles.buttonContainer}>
<View style={SharedStyles.button}>
<Button
title="Set Share Session"
color={Colors.primary}
onPress={() => onSetShareLiveLocationSession(identifier)}
disabled={!identifier} // opcional
/>
</View>
</View>
</Card.Content>
</Card>
);
};

const styles = StyleSheet.create({
input: {
borderWidth: 1,
borderColor: "#ccc",
borderRadius: 6,
padding: 10,
marginBottom: 12,
},
sectionTitle: {
fontWeight: "bold",
marginTop: 8,
color: Colors.primary,
},
logText: {
fontFamily: Platform.OS === "ios" ? "Courier New" : "monospace",
fontSize: 12,
color: "#000",
},
});
11 changes: 11 additions & 0 deletions plugin/android/src/main/java/com/situm/plugin/PluginHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
import es.situm.sdk.location.GeofenceListener;
import es.situm.sdk.navigation.ExternalNavigation;
import es.situm.sdk.userhelper.UserHelperColorScheme;
import es.situm.sdk.location.InternalLocationManager;
import es.situm.sdk.location.ShareLiveLocationOptions;

import static com.situm.plugin.SitumPlugin.EVENT_LOCATION_CHANGED;
import static com.situm.plugin.SitumPlugin.EVENT_LOCATION_ERROR;
Expand Down Expand Up @@ -855,6 +857,15 @@ public void removeRealTimeUpdates() {
getRealtimeManagerInstance().removeRealTimeUpdates();
}

public void startShareLiveLocation(ReadableMap payload) {
Map<String, Object> shareLiveLocationOptionsMap = convertReadableMapToMap(payload);
((InternalLocationManager)SitumSdk.locationManager()).startShareLiveLocation(ShareLiveLocationOptions.fromMap(shareLiveLocationOptionsMap));
}

public void stopShareLiveLocation() {
((InternalLocationManager)SitumSdk.locationManager()).stopShareLiveLocation();
}

public void checkIfPointIsInsideGeoFence(ReadableMap map, Callback callback) {
if (geofencePolygonMap.isEmpty()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public interface SitumPlugin {

void removeRealTimeUpdates();

void startShareLiveLocation(ReadableMap map);

void stopShareLiveLocation();

void checkIfPointInsideGeofence(ReadableMap map, Callback callback);

void invalidateCache();
Expand Down
12 changes: 12 additions & 0 deletions plugin/android/src/main/java/com/situm/plugin/SitumPluginImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,18 @@ public void removeRealTimeUpdates() {
getPluginInstance().removeRealTimeUpdates();
}

@Override
@ReactMethod
public void startShareLiveLocation(ReadableMap map) {
getPluginInstance().startShareLiveLocation(map);
}

@Override
@ReactMethod
public void stopShareLiveLocation() {
getPluginInstance().stopShareLiveLocation();
}

@Override
@ReactMethod
public void checkIfPointInsideGeofence(ReadableMap map, Callback callback) {
Expand Down
14 changes: 14 additions & 0 deletions plugin/ios/SitumPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,20 @@ - (void)didExitedGeofences:(NSArray<SITGeofence *> *)geofences {
[[SITUserHelperManager sharedInstance] autoManage:autoManage];
}


RCT_EXPORT_METHOD(startShareLiveLocation:(NSDictionary *)arguments)
{
if (arguments.count > 0) {
SITShareLiveLocationOptions *shareLiveLocationOptions = [SITShareLiveLocationOptions fromDictionary:arguments];
[((id<SITLocationInterface_Internal>)[SITLocationManager sharedInstance]) startShareLiveLocationWithOptions:shareLiveLocationOptions];
}
}

RCT_EXPORT_METHOD(stopShareLiveLocation)
{
[((id<SITLocationInterface_Internal>)[SITLocationManager sharedInstance]) stopShareLiveLocation];
}

RCT_EXPORT_METHOD(speakAloudText:(NSDictionary *)arguments) {
[_ttsSpeaker speakWithPayload: arguments];
}
Expand Down
25 changes: 25 additions & 0 deletions plugin/src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,31 @@ export default class SitumPlugin {
});
};

/**
* INTERNAL METHOD.
*
* Ask sdk to start sharing its location.
* Do not use this method as it is intended for internal use
* by the map viewer module.
*
* @param startLiveLocationSharing
*/
static startShareLiveLocation = (options: any) => {
RNCSitumPlugin.startShareLiveLocation(options);
};

/**
* INTERNAL METHOD.
*
* Ask sdk to stop sharing its location.
* Do not use this method as it is intended for internal use
* by the map viewer module.
*
*/
static stopShareLiveLocation = () => {
RNCSitumPlugin.stopShareLiveLocation();
};

/**
* INTERNAL METHOD.
*
Expand Down
2 changes: 2 additions & 0 deletions plugin/src/sdk/nativeInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ interface CartographyAPI {
interface LocationAPI {
startPositioning: (locationRequest?: LocationRequest) => void;
stopPositioning: (callback: (response: { success: boolean }) => void) => void;
startShareLiveLocation: (options: any) => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aquí definiría el tipo que espera

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

É un metodo interno, que non queremos que use ningen, en parte esta feito por iso

stopShareLiveLocation: () => void;
}

interface NavigationAPI {
Expand Down
Loading