AI-generated Key Takeaways
-
The
GMTCTripModel
class represents a trip session, which can be a ridesharing or delivery trip, identified by a uniqueTripName
. -
The current state of the trip session can be accessed using the
state
property, and the current trip data can be retrieved through thecurrentTrip
property. -
The
tripName
property provides the specific identifier for the current trip session. -
GMTCTripModel
uses theoptions
property to define the options of the current trip session, and they must be accessed on the main thread. -
Subscribers can register to get callbacks using
registerSubscriber:
and unregister usingunregisterSubscriber:
, both methods are limited to main thread calls, and the trip data is updated automatically once there is a registered subscriber.
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.
Declaration
Swift
var state: GMTCTripModelState { get }
Objective-C
@property (nonatomic, readonly) GMTCTripModelState state;
-
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.
Declaration
Swift
var options: GMTCMutableTripModelOptions { get }
Objective-C
@property (nonatomic, readonly) GMTCMutableTripModelOptions *_Nonnull options;
-
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.
Declaration
Swift
func register(_ subscriber: any GMTCTripModelSubscriber)
Objective-C
- (void)registerSubscriber:(nonnull id<GMTCTripModelSubscriber>)subscriber;
Parameters
subscriber
The instance of
GMTCTripModelSubscriber
to be registered. -
Unregister an instance of
GMTCTripModelSubscriber
for this session, for avoiding the callback. This is recommended when the instance ofGMTCTripModelSubscriber
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
Swift
func unregisterSubscriber(_ subscriber: any GMTCTripModelSubscriber)
Objective-C
- (void)unregisterSubscriber:(nonnull id<GMTCTripModelSubscriber>)subscriber;
Parameters
subscriber
The instance of
GMTCTripModelSubscriber
to be registered. -
Unavailable
Use
-tripModelForTripName:
ofGMTCTripService
instead.Declaration
Objective-C
- (nonnull instancetype)init;