Initialize the Driver SDK
Stay organized with collections
Save and categorize content based on your preferences.
To start sending vehicle updates to Fleet Engine and the customer backend,
create a GMTDRidesharingDriverAPI
instance that includes the providerID
,
vehicleID
, driverContext
, and accessTokenProvider
.
The providerID
is the same as the Project ID of your Google Cloud
Project. For information on setting up the Google Cloud Project, see
Create your Fleet Engine project.
The following example shows how to create a GMTDRidesharingDriverAPI
instance.
Swift
import GoogleRidesharingDriver
private let providerID = "INSERT_YOUR_PROVIDER_ID"
class SampleViewController: UIViewController {
private let mapView: GMSMapView
override func viewDidLoad() {
super.viewDidLoad()
let vehicleID = "INSERT_CREATED_VEHICLE_ID"
let accessTokenProvider = SampleAccessTokenProvider()
let driverContext = GMTDDriverContext(
accessTokenProvider: accessTokenProvider,
providerID: providerID,
vehicleID: vehicleID,
navigator: mapView.navigator)
let ridesharingDriverAPI = GMTDRidesharingDriverAPI(driverContext: driverContext)
}
}
Objective-C
#import "SampleViewController.h"
#import "SampleAccessTokenProvider.h"
#import <GoogleRidesharingDriver/GoogleRidesharingDriver.h>
static NSString *const PROVIDER_ID = @"INSERT_YOUR_PROVIDER_ID";
@implementation SampleViewController {
GMSMapView *_mapView;
}
- (void)viewDidLoad {
NSString *vehicleID = @"INSERT_CREATED_VEHICLE_ID";
SampleAccessTokenProvider *accessTokenProvider =
[[SampleAccessTokenProvider alloc] init];
GMTDDriverContext *driverContext =
[[GMTDDriverContext alloc] initWithAccessTokenProvider:accessTokenProvider
providerID:PROVIDER_ID
vehicleID:vehicleID
navigator:_mapView.navigator];
GMTDRidesharingDriverAPI *ridesharingDriverAPI = [[GMTDRidesharingDriverAPI alloc] initWithDriverContext:driverContext];
}
What's next
Get the vehicle ready
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-28 UTC.
[null,null,["Last updated 2025-08-28 UTC."],[[["\u003cp\u003eCreate a \u003ccode\u003eGMTDRidesharingDriverAPI\u003c/code\u003e instance to initiate vehicle updates to Fleet Engine and your backend system.\u003c/p\u003e\n"],["\u003cp\u003eThis instance needs \u003ccode\u003eproviderID\u003c/code\u003e (your Google Cloud Project ID), \u003ccode\u003evehicleID\u003c/code\u003e, \u003ccode\u003edriverContext\u003c/code\u003e, and \u003ccode\u003eaccessTokenProvider\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the provided Swift and Objective-C code examples for implementation guidance on creating the \u003ccode\u003eGMTDRidesharingDriverAPI\u003c/code\u003e instance.\u003c/p\u003e\n"]]],[],null,["# Initialize the Driver SDK\n\nTo start sending vehicle updates to Fleet Engine and the customer backend,\ncreate a `GMTDRidesharingDriverAPI` instance that includes the `providerID`,\n`vehicleID`, `driverContext`, and `accessTokenProvider`.\n\nThe `providerID` is the same as the **Project ID** of your Google Cloud\nProject. For information on setting up the Google Cloud Project, see\n[Create your Fleet Engine project](/maps/documentation/mobility/fleet-engine/essentials/set-up-fleet/create-project).\n\nThe following example shows how to create a `GMTDRidesharingDriverAPI` instance. \n\n### Swift\n\n import GoogleRidesharingDriver\n\n private let providerID = \"INSERT_YOUR_PROVIDER_ID\"\n\n class SampleViewController: UIViewController {\n private let mapView: GMSMapView\n\n override func viewDidLoad() {\n super.viewDidLoad()\n\n let vehicleID = \"INSERT_CREATED_VEHICLE_ID\"\n let accessTokenProvider = SampleAccessTokenProvider()\n let driverContext = GMTDDriverContext(\n accessTokenProvider: accessTokenProvider,\n providerID: providerID,\n vehicleID: vehicleID,\n navigator: mapView.navigator)\n let ridesharingDriverAPI = GMTDRidesharingDriverAPI(driverContext: driverContext)\n }\n }\n\n### Objective-C\n\n #import \"SampleViewController.h\"\n #import \"SampleAccessTokenProvider.h\"\n #import \u003cGoogleRidesharingDriver/GoogleRidesharingDriver.h\u003e\n\n static NSString *const PROVIDER_ID = @\"INSERT_YOUR_PROVIDER_ID\";\n\n @implementation SampleViewController {\n GMSMapView *_mapView;\n }\n\n - (void)viewDidLoad {\n NSString *vehicleID = @\"INSERT_CREATED_VEHICLE_ID\";\n SampleAccessTokenProvider *accessTokenProvider =\n [[SampleAccessTokenProvider alloc] init];\n GMTDDriverContext *driverContext =\n [[GMTDDriverContext alloc] initWithAccessTokenProvider:accessTokenProvider\n providerID:PROVIDER_ID\n vehicleID:vehicleID\n navigator:_mapView.navigator];\n\n GMTDRidesharingDriverAPI *ridesharingDriverAPI = [[GMTDRidesharingDriverAPI alloc] initWithDriverContext:driverContext];\n }\n\nWhat's next\n-----------\n\n[Get the vehicle ready](/maps/documentation/mobility/driver-sdk/on-demand/ios/vehicle-ready)"]]