初始化驱动程序 SDK
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如需开始向 Fleet Engine 和客户后端发送车辆更新,请创建一个包含 providerID
、vehicleID
、driverContext
和 accessTokenProvider
的 GMTDDeliveryDriverAPI
实例。
providerID
与您的 Google Cloud 项目的项目 ID 相同。如需了解如何设置 Google Cloud 项目,请参阅创建 Fleet Engine 项目。
以下示例展示了如何创建 GMTDDeliveryDriverAPI
实例。
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];
GMTDDeliveryDriverAPI *deliveryDriverAPI = [[GMTDDeliveryDriverAPI alloc] initWithDriverContext:driverContext];
}
后续步骤
准备车辆
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eTo initiate vehicle updates to Fleet Engine and the customer backend, create a \u003ccode\u003eGMTDDeliveryDriverAPI\u003c/code\u003e instance.\u003c/p\u003e\n"],["\u003cp\u003eThis instance requires your Google Cloud Project ID (\u003ccode\u003eproviderID\u003c/code\u003e), \u003ccode\u003evehicleID\u003c/code\u003e, \u003ccode\u003edriverContext\u003c/code\u003e, and \u003ccode\u003eaccessTokenProvider\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAn Objective-C code example demonstrates the creation of a \u003ccode\u003eGMTDDeliveryDriverAPI\u003c/code\u003e instance using these parameters.\u003c/p\u003e\n"],["\u003cp\u003eFor setup instructions of your Google Cloud Project, refer to the provided documentation link.\u003c/p\u003e\n"],["\u003cp\u003eThe next step involves getting the vehicle ready, as detailed in the provided link.\u003c/p\u003e\n"]]],[],null,["# Initialize the Driver SDK\n\nTo start sending vehicle updates to Fleet Engine and the customer backend,\ncreate a `GMTDDeliveryDriverAPI` instance that includes the\n`providerID`, `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 `GMTDDeliveryDriverAPI` instance. \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 GMTDDeliveryDriverAPI *deliveryDriverAPI = [[GMTDDeliveryDriverAPI alloc] initWithDriverContext:driverContext];\n }\n\nWhat's next\n-----------\n\n[Get the vehicle ready](/maps/documentation/mobility/driver-sdk/scheduled/ios/vehicle-ready)"]]