MLIMPassenger Class Reference

Inherits from MLIMRuntimeObject : NSObject
Declared in MLIMPassenger.h

Overview

A MLIMPassenger object represent a passenger.

A passenger can have some custom attributes. You can access them using [passenger objectForKey:@"attrname"] or passenger[@"attrname"] syntax.

You can also create a subclass that inherits from MLIMPassenger, defining some dynamic property to access the attributes. A simple example:

@code @interface MyPassenger : MLIMPassenger @property (nonatomic) int age; @end

@implementation MYPassenger // !!!IMPORTANT!!! The property age must be declared as dynamic property. @dynamic age;

@end

// Then, you can get the passenger’s age by using passenger.age syntax. @endcode

  pid

The passenger id.

@property (nonatomic, strong) NSString *pid

Declared In

MLIMPassenger.h

+ passengerWithId:

Create an instance of MLIMPassenger with passenger id.

+ (instancetype)passengerWithId:(NSString *)pid

Parameters

pid

the passenger id

Return Value

A new instance of MLIMPassenger.

Declared In

MLIMPassenger.h

+ createOrUpdatePassengerWithAttributes:completion:

Create or update a passenger with attributes.

+ (void)createOrUpdatePassengerWithAttributes:(NSDictionary<NSDictionary*,id> *)attributes completion:(void ( ^ ) ( MLIMPassenger *_Nullable passenger , NSError *_Nullable error ))completion

Parameters

attributes

The custom passenger attributes.

completion

A block to notify the result.

Discussion

If passenge with the id attributes[@"id"] exsits, update it, otherwise, create a new passenger.

The api always create new passenger if attributes[@“id”] is empty.

Declared In

MLIMPassenger.h

– updatePassengerAttributes:completion:

Update passenger attributes. The keys that are not in the attributes will not be updated.

- (void)updatePassengerAttributes:(NSDictionary<NSString*,id> *)attributes completion:(MLIMBooleanResultBlock)completion

Parameters

attributes

Attributes to update

completion

A block to notify the resutl.

Declared In

MLIMPassenger.h

– fetchWithCompletion:

Fetch the passenger’s attributes.

- (void)fetchWithCompletion:(MLIMBooleanResultBlock)completion

Parameters

completion

A block to notify the result.

Declared In

MLIMPassenger.h

– getHistoryMessagesWithUser:beforeTime:limit:completion:

Get history messages chat with user.

- (void)getHistoryMessagesWithUser:(NSString *)userId beforeTime:(NSTimeInterval)ts limit:(int)limit completion:(void ( ^ ) ( NSArray<MLIMMessage*> *_Nullable messages , NSError *_Nullable error ))completion

Parameters

userId

The talking target

ts

The timestamp

limit

Limit for message count return

completion

A block to notify the result.

Declared In

MLIMPassenger.h

– countHistoryMessagesWithUser:afterTime:block:

Get the count of history messages with a user from ts to now.

- (void)countHistoryMessagesWithUser:(NSString *)userId afterTime:(NSTimeInterval)ts block:(MLIMIntegerResultBlock)block

Parameters

userId

The user Id

ts

The start time. Default is 0, meaning all messages, NOT RECOMMENDED.

block

The block will be executed on the main queue. It should have the following signatures: (NSInteger number, NSError *error)

Declared In

MLIMPassenger.h