This is a sample application that show cases developers how to integrate with the React Native: DriverSDK library.
- This library depends on the LMFS backend available in https://github.com/googlemaps/last-mile-fleet-solution-samples/tree/main/backend. This package provides docker-compose files to run the backend services at
/example/tools/backendfolder. For more information, please refer to the README file in the tools/backend folder of the example app. - Once the backend is setup, create a delivery vehicle and keep the vehicleId handy. In order to make it easier to create vehicles with tasks, you can use the
/upload-delivery-config.htmlendpoint on the backend. example json - Configure the VEHICLE_ID using one of the following methods:
- Option 1: .env file (Recommended) - Add the vehicle ID to your
.envfile in theexamplefolder:LMFS_VEHICLE_ID=your_vehicle_id - Option 2: Direct Input - When you start the app, you can enter the vehicle ID directly in the "VEHICLE_ID Not Configured" screen.
- Option 3: Code Update - Go to the App.tsx file and update the VEHICLE_ID_DEFAULT constant with your vehicle ID.
- Option 1: .env file (Recommended) - Add the vehicle ID to your
-
Run
yarn installin repository root directory. -
Open the
example/LMFS/androidfolder in Android Studio and add your api key in local.properties by adding a line like this:MAPS_API_KEY=YOUR_API_KEY- make sure that this key is pointing to a Google Cloud project which had Nav SDK enabled.- To enable Nav SDK in your Android project follow this guide: https://developers.google.com/maps/documentation/navigation/android-sdk/set-up-project
-
Run
yarn installin repository root directory. -
To enable Nav SDK in your iOS project follow this guide: https://developers.google.com/maps/documentation/navigation/ios-sdk/config
-
Go to the ios folder and run
pod install. -
Copy the
Keys.plist.samplefile located inexample/LMFS/ios/SampleApp/to a new file namedKeys.plist. This file is git ignored and won't be accidentally committed. In your Google cloud console, add the Google API key to the project and add this newly created API key to theKeys.plistfile.<key>API_KEY</key> <string>Your API KEY</string>
Use yarn run react-native run-android or yarn run react-native run-ios depending the platform.
To make sure that location updates are propagating properly, you can use Fleet Engine logs.
- Go to https://console.cloud.google.com/ and select the relevant project.
- Open the "Logs Explorer".
- Run Query
jsonPayload.request.deliveryVehicleId="vehicle_id"andjsonPayload.@type="type.googleapis.com/maps.fleetengine.v1.UpdateDeliveryVehicleLog". - This will show the location updates sent through the library.
- Make sure the backend is running by following steps at README.
- Open Fleet Tracking at http://localhost:8091/fleet_tracking.html (or the port you have configured in your .env file).
- Enter the vehicleId and see the location updates on the map.