初始化驱动程序 SDK

如需开始向 Fleet Engine 和客户后端发送车辆更新,请创建包含 providerIDvehicleIDdriverContextaccessTokenProviderGMTDDeliveryDriverAPI 实例。

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];
}

后续步骤

准备好车辆