設定 Google Cloud 控制台專案
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
如要為 Driver SDK 設定行動應用程式專案和 Google Cloud 控制台專案,請按照下列步驟操作:
- 如果您沒有 Google Cloud 控制台開發專案,也沒有行動專案的 API 金鑰,請進行設定。詳情請參閱「建立 Fleet Engine 專案」一文。
- 在 Google Cloud 控制台中,選取您用於 Fleet Engine 的 Google Cloud 控制台專案和 API 金鑰。
- 選取「API 和服務」,依「地圖」篩選,然後搜尋並啟用 Maps SDK for iOS。
將 API 金鑰加進專案
以下範例說明如何在 Xcode 中將 API 金鑰新增至專案:
Swift
將 API 金鑰新增到您的 AppDelegate.swift
中,如下所示:
新增下列匯入陳述式:
import GoogleMaps
import GoogleRidesharingDriver
將以下內容新增至 application(_:didFinishLaunchingWithOptions:)
方法:
GMSServices.provideAPIKey("YOUR_API_KEY")
Objective-C
將 API 金鑰新增到您的 AppDelegate.m
中,如下所示:
新增下列匯入陳述式:
@import GoogleMaps;
@import GoogleGoogleRidesharingDriver;
將以下內容新增至 application:didFinishLaunchingWithOptions:
方法:
[GMSServices provideAPIKey:@"YOUR_API_KEY"];
後續步驟
建立驗證權杖
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\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)"]]