GoogleRidesharingConsumer Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
GMTCTripModel
@interface GMTCTripModel : NSObject
A class representing a trip session. A trip session will provide trip info update periodically
after started, it can be either a ridesharing or a delivery trip, and each trip session is
identified by a TripName.
-
Returns the current session state.
-
Returns the current trip data.
Declaration
Swift
var currentTrip: GMTSTrip? { get }
Objective-C
@property (nonatomic, readonly, nullable) GMTSTrip *currentTrip;
-
Returns the associated trip name.
Declaration
Swift
var tripName: String { get }
Objective-C
@property (nonatomic, readonly) NSString *_Nonnull tripName;
-
Specifies the options of the current trip session. This property should only be accessed in the
main thread.
-
Register an instance of GMTCTripModelSubscriber
for this session.
Call this API before you can get any callbacks.
This method is only allowed to be called in the main thread.
Note that the tripModel will be active (e.g. trip data is being updated/refreshed) automatically
once a subscriber is registered.
-
Unregister an instance of GMTCTripModelSubscriber
for this session, for avoiding the callback.
This is recommended when the instance of GMTCTripModelSubscriber
needs to be dealloced.
This method is only allowed to be called in the main thread.
Note that if there are no subscribers registered, the tripModel will automatically stop the trip
session.
-
Declaration
Objective-C
- (nonnull instancetype)init;
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-27 UTC.
[null,null,["Last updated 2025-08-27 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eGMTCTripModel\u003c/code\u003e class represents a trip session, which can be a ridesharing or delivery trip, identified by a unique \u003ccode\u003eTripName\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe current state of the trip session can be accessed using the \u003ccode\u003estate\u003c/code\u003e property, and the current trip data can be retrieved through the \u003ccode\u003ecurrentTrip\u003c/code\u003e property.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003etripName\u003c/code\u003e property provides the specific identifier for the current trip session.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eGMTCTripModel\u003c/code\u003e uses the \u003ccode\u003eoptions\u003c/code\u003e property to define the options of the current trip session, and they must be accessed on the main thread.\u003c/p\u003e\n"],["\u003cp\u003eSubscribers can register to get callbacks using \u003ccode\u003eregisterSubscriber:\u003c/code\u003e and unregister using \u003ccode\u003eunregisterSubscriber:\u003c/code\u003e, both methods are limited to main thread calls, and the trip data is updated automatically once there is a registered subscriber.\u003c/p\u003e\n"]]],[],null,["# GoogleRidesharingConsumer Framework Reference\n\nGMTCTripModel\n=============\n\n @interface GMTCTripModel : NSObject\n\nA class representing a trip session. A trip session will provide trip info update periodically\nafter started, it can be either a ridesharing or a delivery trip, and each trip session is\nidentified by a TripName.\n- `\n ``\n ``\n `\n\n ### [state](#/c:objc(cs)GMTCTripModel(py)state)\n\n `\n ` \n Returns the current session state. \n\n #### Declaration\n\n Swift \n\n var state: ../Enums/GMTCTripModelState.html { get }\n\n Objective-C \n\n @property (nonatomic, readonly) ../Enums/GMTCTripModelState.html state;\n\n- `\n ``\n ``\n `\n\n ### [currentTrip](#/c:objc(cs)GMTCTripModel(py)currentTrip)\n\n `\n ` \n Returns the current trip data. \n\n #### Declaration\n\n Swift \n\n var currentTrip: ../Classes/GMTSTrip.html? { get }\n\n Objective-C \n\n @property (nonatomic, readonly, nullable) ../Classes/GMTSTrip.html *currentTrip;\n\n- `\n ``\n ``\n `\n\n ### [tripName](#/c:objc(cs)GMTCTripModel(py)tripName)\n\n `\n ` \n Returns the associated trip name. \n\n #### Declaration\n\n Swift \n\n var tripName: String { get }\n\n Objective-C \n\n @property (nonatomic, readonly) NSString *_Nonnull tripName;\n\n- `\n ``\n ``\n `\n\n ### [options](#/c:objc(cs)GMTCTripModel(py)options)\n\n `\n ` \n Specifies the options of the current trip session. This property should only be accessed in the\n main thread. \n\n #### Declaration\n\n Swift \n\n var options: ../Classes/GMTCMutableTripModelOptions.html { get }\n\n Objective-C \n\n @property (nonatomic, readonly) ../Classes/GMTCMutableTripModelOptions.html *_Nonnull options;\n\n- `\n ``\n ``\n `\n\n ### [-registerSubscriber:](#/c:objc(cs)GMTCTripModel(im)registerSubscriber:)\n\n `\n ` \n Register an instance of [GMTCTripModelSubscriber](../Protocols/GMTCTripModelSubscriber.html) for this session.\n Call this API before you can get any callbacks.\n This method is only allowed to be called in the main thread.\n\n Note that the tripModel will be active (e.g. trip data is being updated/refreshed) automatically\n once a subscriber is registered. \n\n #### Declaration\n\n Swift \n\n func register(_ subscriber: any ../Protocols/GMTCTripModelSubscriber.html)\n\n Objective-C \n\n - (void)registerSubscriber:(nonnull id\u003c../Protocols/GMTCTripModelSubscriber.html\u003e)subscriber;\n\n #### Parameters\n\n |--------------------|--------------------------------------------------------------------------------------------------------|\n | ` `*subscriber*` ` | The instance of [GMTCTripModelSubscriber](../Protocols/GMTCTripModelSubscriber.html) to be registered. |\n\n- `\n ``\n ``\n `\n\n ### [-unregisterSubscriber:](#/c:objc(cs)GMTCTripModel(im)unregisterSubscriber:)\n\n `\n ` \n Unregister an instance of [GMTCTripModelSubscriber](../Protocols/GMTCTripModelSubscriber.html) for this session, for avoiding the callback.\n This is recommended when the instance of [GMTCTripModelSubscriber](../Protocols/GMTCTripModelSubscriber.html) needs to be dealloced.\n This method is only allowed to be called in the main thread.\n\n Note that if there are no subscribers registered, the tripModel will automatically stop the trip\n session. \n\n #### Declaration\n\n Swift \n\n func unregisterSubscriber(_ subscriber: any ../Protocols/GMTCTripModelSubscriber.html)\n\n Objective-C \n\n - (void)unregisterSubscriber:(nonnull id\u003c../Protocols/GMTCTripModelSubscriber.html\u003e)subscriber;\n\n #### Parameters\n\n |--------------------|--------------------------------------------------------------------------------------------------------|\n | ` `*subscriber*` ` | The instance of [GMTCTripModelSubscriber](../Protocols/GMTCTripModelSubscriber.html) to be registered. |\n\n- `\n ``\n ``\n `\n\n ### [-init](#/c:objc(cs)GMTCTripModel(im)init)\n\n `\n ` \n Unavailable \n Use `-tripModelForTripName:` of [GMTCTripService](../Classes/GMTCTripService.html) instead. \n\n #### Declaration\n\n Objective-C \n\n - (nonnull instancetype)init;"]]