This is a sample application that show cases developers how to integrate with the React Native: DriverSDK library.
-
This library depends on the ODRD backend available in https://github.com/googlemaps/java-on-demand-rides-deliveries-stub-provider. Please make sure to set this up before proceeding. 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 unique vehicle and keep the vehicleId handy. To create a vehicle, you can trigger POST request with the desired fields. Example:
Body:
{
"vehicleId": "vehicle_1234",
"supportedTripTypes": ["EXCLUSIVE"],
"backToBackEnabled": false,
"maximumCapacity": 4
}
Curl command:
curl -X POST http://localhost:8092/vehicle/new \
-H "Content-Type: application/json" \
-d '{
"vehicleId": "vehicle_1234",
"supportedTripTypes": ["EXCLUSIVE"],
"backToBackEnabled": false,
"maximumCapacity": 4
}'- Configure the VEHICLE_ID using one of the following methods:
- Option 1: .env file (Recommended) - Add the vehicle ID to your
.envfile in theexamplefolder:ODRD_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/ODRD/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/ODRD/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.vehicleId="vehicle_id"andjsonPayload.@type="type.googleapis.com/maps.fleetengine.v1.UpdateVehicleLog". - This will show the location updates sent through the library.