This repository contains source code for the following sample apps.
- The Driver SDK sample, available in two languages:
- Swift: in
swift/driver_swiftuidirectory. - Objective-C: in
objectivec_samples/Driverdirectory.
- Swift: in
- The Consumer SDK sample, available in two languages:
- Swift: in
swift/consumer_swiftuidirectory. - Objective-C: in
objectivec_samples/Consumerdirectory.
- Swift: in
Use the following guide to build and run a basic consumer and a driver app that uses these SDK samples. This will help you integrate your app with the On-demand Rides and Deliveries Solution backend services.
After completing this guide, you should have an app that can display an active trip, respond to trip updates, and handle trip errors.
This guide assumes you have done all of the following.
-
Established a Cloud project service account with a project ID needed for running the sample apps.
-
Set up Fleet Engine as described in Getting Started with Fleet Engine
-
Set up the provider backend and have it running.
-
Authenticated your service by visiting https://cpdc-eap.googlesource.com/new-password and setting up a git cookie.
-
Installed CocoaPods on the development machine
sudo gem install cocoapods
Refer to the CocoaPods Getting Started guide for more details.
After you have met all prerequisites:
-
Open a terminal and go to the directory containing the Podfile:
cd <path-to-project>
-
Run the
pod installcommand. This installs the pods specified in the Podfile, along with any dependencies they have.pod install
-
Close Xcode, and then open (double-click) your project's
.xcworkspacefile to launch Xcode. From this time onwards, you must use the.xcworkspacefile to open the project, not the.xcodeprojfile. -
Follow the Getting an API Key guide to add your Maps API key to your app.
-
For Swift, update
mapsAPIKeyinAPIConstants.swiftfor both Consumer and Driver. -
For Objective-C, update
kMapsAPIKeyinGRSCAPIConstants.mfor the Consumer app and inGRSDAPIConstants.mfor the Driver app.
-
-
(Optional) Follow the Use API Keys with Location Selection API guide to add your Location Selection API key to your app.
-
For Swift, update
locationSelectionAPIKeyinAPIConstants.swiftfor Consumer. -
For Objective-C, update
kLocationSelectionAPIKeyinGRSCAPIConstants.mfor the Consumer app.
-
-
Add the Provider ID to your app. The Provider ID is the Project ID of the Google Cloud Project that contains the service account used to call the Fleet Engine APIs.
-
For Swift, update
providerIDinAPIConstants.swiftfor both Consumer and Driver. -
For Objective-C, update
kProviderIDinGRSCAPIConstants.mfor the Consumer app and inGRSDAPIConstants.mfor the Driver app.
-
Then the project should run normally.
As of version 3.3.0, these samples introduce the Driver SDK and Consumer SDKs compatibility together in a single app. This version also removes those public classes from the Driver SDK source code that are only used by the Consumer SDK. To use the removed classes in the Driver SDK sample apps, the app must include Consumer SDK v3.3.0+ as a dependency.
Note: As of version 3.3.0 onward, Driver SDK sample apps developed against the Driver & Consumer SDKs are compatible only with SDK versions 3.3.0 and higher. Correspondingly, Driver SDK sample apps updated prior to versions 3.3.0 can only work with Driver SDK version lower than 3.3.0.
This sample uses Google Maps Platform services. Use of Google Maps Platform services through this sample is subject to the Google Maps Platform Terms of Service.
European Economic Area (EEA) developers
If your billing address is in the European Economic Area, effective on 8 July 2025, the Google Maps Platform EEA Terms of Service will apply to your use of the Services. Functionality varies by region. Learn more.
Copyright 2022 Google, Inc.
Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
additional information regarding copyright ownership. The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.