初始化驅動程式 SDK

如要開始將車輛更新資訊傳送至 Fleet Engine 與客戶後端, 建立 GMTDDeliveryDriverAPI 執行個體,其中包含 providerIDvehicleIDdriverContextaccessTokenProvider

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

後續步驟

準備車輛