เริ่มต้น SDK ของไดรเวอร์
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
หากต้องการเริ่มส่งข้อมูลอัปเดตยานพาหนะไปยัง Fleet Engine และแบ็กเอนด์ของลูกค้า
ให้สร้างอินสแตนซ์ GMTDDeliveryDriverAPI
ที่มี
providerID
, vehicleID
, driverContext
และ accessTokenProvider
providerID
จะเหมือนกับรหัสโปรเจ็กต์ของโปรเจ็กต์ Google Cloud
ดูข้อมูลเกี่ยวกับการตั้งค่าโปรเจ็กต์ 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 Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-31 UTC
[null,null,["อัปเดตล่าสุด 2025-08-31 UTC"],[[["\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)"]]