Định cấu hình dự án trên Google Cloud Console
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Để định cấu hình dự án ứng dụng di động và dự án trên bảng điều khiển Google Cloud cho Driver SDK, hãy làm theo các bước sau:
- Nếu không có dự án phát triển trên Google Cloud Console và khoá API cho dự án di động của mình, bạn cần thiết lập một dự án. Để biết thêm thông tin, hãy xem bài viết Tạo dự án Fleet Engine.
- Trong Google Cloud Console, hãy chọn cùng một dự án trên Google Cloud Console và khoá API mà bạn đang dùng cho Fleet Engine.
- Chọn API và dịch vụ, lọc theo Maps, sau đó tìm và bật Maps SDK cho iOS.
Thêm khoá API vào dự án
Các ví dụ sau đây cho thấy cách thêm khoá API vào dự án của bạn trong Xcode:
Swift
Thêm khoá API vào AppDelegate.swift
của bạn như sau:
Thêm các câu lệnh nhập sau:
import GoogleMaps
import GoogleRidesharingDriver
Thêm nội dung sau vào phương thức application(_:didFinishLaunchingWithOptions:)
:
GMSServices.provideAPIKey("YOUR_API_KEY")
Objective-C
Thêm khoá API vào AppDelegate.m
của bạn như sau:
Thêm các câu lệnh nhập sau:
@import GoogleMaps;
@import GoogleGoogleRidesharingDriver;
Thêm nội dung sau vào phương thức application:didFinishLaunchingWithOptions:
:
[GMSServices provideAPIKey:@"YOUR_API_KEY"];
Bước tiếp theo
Tạo mã thông báo xác thực
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-31 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\u003cp\u003eSet up a Google Cloud console development project and API key for your mobility project if you don't have one already.\u003c/p\u003e\n"],["\u003cp\u003eEnable the Maps SDK for iOS within your Google Cloud console project.\u003c/p\u003e\n"],["\u003cp\u003eAdd your API key to your iOS project (\u003ccode\u003eAppDelegate\u003c/code\u003e file) using the provided code snippets for either Swift or Objective-C.\u003c/p\u003e\n"],["\u003cp\u003eAfter configuration, proceed to create authentication tokens for Driver SDK functionalities.\u003c/p\u003e\n"]]],[],null,["# Configure a Google Cloud console project\n\nTo configure your mobile app project and Google Cloud console project for the Driver\nSDK, follow these steps:\n\n1. If you don't have a Google Cloud console development project and an API key for your mobility project, you need to set one up. For more information, see [Create your Fleet Engine project](/maps/documentation/mobility/fleet-engine/essentials/set-up-fleet/create-project).\n2. In the Google Cloud console, select the same Google Cloud console project and API key that you are using for Fleet Engine.\n3. Select **APIs \\& Services** , filter by **Maps**, and then search for and enable the Maps SDK for iOS.\n\nAdd your API key to the project\n-------------------------------\n\nThe following examples show how to add the API key to your project in Xcode: \n\n### Swift\n\nAdd your API key to your `AppDelegate.swift` as follows:\n\n1. Add the following import statements:\n\n import GoogleMaps\n import GoogleRidesharingDriver\n\n2. Add the following to your `application(_:didFinishLaunchingWithOptions:)`\n method:\n\n GMSServices.provideAPIKey(\"\u003cvar translate=\"no\"\u003eYOUR_API_KEY\u003c/var\u003e\")\n\n### Objective-C\n\nAdd your API key to your `AppDelegate.m` as follows:\n\n1. Add the following import statements:\n\n @import GoogleMaps;\n @import GoogleGoogleRidesharingDriver;\n\n2. Add the following to your `application:didFinishLaunchingWithOptions:`\n method:\n\n [GMSServices provideAPIKey:@\"\u003cvar translate=\"no\"\u003eYOUR_API_KEY\u003c/var\u003e\"];\n\nWhat's next\n-----------\n\n[Create authentication tokens](/maps/documentation/mobility/driver-sdk/scheduled/ios/authenticate)"]]