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;