GMTCTripModel
@interface GMTCTripModel : NSObjectA 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
GMTCTripModelSubscriberfor 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
subscriberThe instance of
GMTCTripModelSubscriberto be registered. -
Unregister an instance of
GMTCTripModelSubscriberfor this session, for avoiding the callback. This is recommended when the instance ofGMTCTripModelSubscriberneeds 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
subscriberThe instance of
GMTCTripModelSubscriberto be registered. -
Unavailable
Use
-tripModelForTripName:ofGMTCTripServiceinstead.Declaration
Objective-C
- (nonnull instancetype)init;