Inicializar o SDK do consumidor
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Para começar a compartilhar trajetos do Fleet Engine e do back-end do cliente,
é necessário inicializar o SDK do consumidor no seu aplicativo iOS.
O providerID
é o mesmo que o ID do projeto do seu projeto do Google Cloud. Para informações sobre como configurar o projeto do Google Cloud, consulte
Criar seu projeto do Fleet Engine.
Os exemplos a seguir mostram como inicializar o SDK Consumer no seu app.
Swift
/*
* AppDelegate.swift
*/
import GoogleRidesharingConsumer
import GoogleMaps
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Register your API key for GMSServices.
GMSServices.provideAPIKey(yourMapsAPIKey)
// Set the instance of the SampleAccessTokenProvider.
GMTCServices.setAccessTokenProvider(SampleAccessTokenProvider(), providerID: yourProviderID)
// Other initialization code ...
return true
}
}
Objective-C
/*
* AppDelegate.m
*/
#import <GoogleMaps/GoogleMaps.h>
#import <GoogleRidesharingConsumer/GoogleRidesharingConsumer.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Register your API key for GMSServices.
[GMSServices provideAPIKey:yourMapsAPIKey];
//Set the instance of the AccessTokenFactory.
[GMTCServices setAccessTokenProvider:[[SampleAccessTokenProvider alloc] init]
providerID:yourProviderID];
// Other initialization code ...
return YES;
}
@end
A seguir
Configurar um mapa
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2025-08-31 UTC.
[null,null,["Última atualização 2025-08-31 UTC."],[[["\u003cp\u003eTo share journeys from Fleet Engine and your backend, you must initialize the Consumer SDK in your iOS application using your Google Cloud Project ID (\u003ccode\u003eproviderID\u003c/code\u003e) and API key.\u003c/p\u003e\n"],["\u003cp\u003eThe provided Swift and Objective-C code snippets demonstrate how to initialize the SDK within your app's AppDelegate.\u003c/p\u003e\n"],["\u003cp\u003eAfter initializing the SDK, you can proceed with setting up a map to display journey information using the provided documentation link.\u003c/p\u003e\n"]]],[],null,["To start sharing journeys from Fleet Engine and the customer backend,\nyou need to initialize the Consumer SDK in your iOS application.\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 examples show how to initialize the Consumer SDK in your app. \n\nSwift \n\n /*\n * AppDelegate.swift\n */\n import GoogleRidesharingConsumer\n import GoogleMaps\n\n @UIApplicationMain\n class AppDelegate: UIResponder, UIApplicationDelegate {\n\n func application(_ application: UIApplication,\n didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -\u003e Bool {\n\n // Register your API key for GMSServices.\n\n GMSServices.provideAPIKey(yourMapsAPIKey)\n\n // Set the instance of the SampleAccessTokenProvider.\n\n GMTCServices.setAccessTokenProvider(SampleAccessTokenProvider(), providerID: yourProviderID)\n\n // Other initialization code ...\n\n return true\n }\n }\n\nObjective-C \n\n /*\n * AppDelegate.m\n */\n #import \u003cGoogleMaps/GoogleMaps.h\u003e\n #import \u003cGoogleRidesharingConsumer/GoogleRidesharingConsumer.h\u003e\n\n @implementation AppDelegate\n\n - (BOOL)application:(UIApplication *)application\n didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n //Register your API key for GMSServices.\n [GMSServices provideAPIKey:yourMapsAPIKey];\n\n //Set the instance of the AccessTokenFactory.\n [GMTCServices setAccessTokenProvider:[[SampleAccessTokenProvider alloc] init]\n providerID:yourProviderID];\n\n // Other initialization code ...\n return YES;\n }\n\n @end\n\nWhat's Next\n\n[Set up a map](/maps/documentation/mobility/journey-sharing/on-demand/ios/create-ui)"]]