配置 Google Cloud 控制台项目
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如需为 Driver SDK 配置移动应用项目和 Google Cloud 控制台项目,请按以下步骤操作:
- 如果您没有 Google Cloud 控制台开发项目和出行项目的 API 密钥,则需要进行设置。如需了解详情,请参阅创建 Fleet Engine 项目。
- 在 Google Cloud 控制台中,选择您用于 Fleet Engine 的同一 Google Cloud 控制台项目和 API 密钥。
- 选择 API 和服务,按 Maps 过滤,然后搜索并启用 Maps SDK for iOS。
将您的 API 密钥添加到项目中
以下示例展示了如何在 Xcode 中将 API 密钥添加到项目中:
Swift
按照以下方法向 AppDelegate.swift
添加 API 密钥:
添加以下 import 语句:
import GoogleMaps
import GoogleRidesharingDriver
将以下代码添加到 application(_:didFinishLaunchingWithOptions:)
方法中:
GMSServices.provideAPIKey("YOUR_API_KEY")
Objective-C
按照以下方法向 AppDelegate.m
添加 API 密钥:
添加以下 import 语句:
@import GoogleMaps;
@import GoogleGoogleRidesharingDriver;
将以下代码添加到 application:didFinishLaunchingWithOptions:
方法中:
[GMSServices provideAPIKey:@"YOUR_API_KEY"];
后续步骤
创建身份验证令牌
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eTo use the Driver SDK, you must first set up a Google Cloud console project and an API key for your mobility project if you haven't already.\u003c/p\u003e\n"],["\u003cp\u003eEnsure the same Google Cloud project and API key used for Fleet Engine are selected, and enable the Maps SDK for iOS within the APIs & Services section.\u003c/p\u003e\n"],["\u003cp\u003eIntegrate your API key into your Xcode project by adding it to \u003ccode\u003eAppDelegate\u003c/code\u003e and utilizing necessary import statements (\u003ccode\u003eGoogleMaps\u003c/code\u003e, \u003ccode\u003eGoogleRidesharingDriver\u003c/code\u003e).\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/on-demand/ios/authenticate)"]]