MLIMUser Class Reference

Inherits from MLIMRuntimeObject : NSObject
Declared in MLIMUser.h

Overview

A representation of current logged in user.

  uid

The user ID.

@property (nonatomic, strong) NSString *uid

Declared In

MLIMUser.h

  username

The username.

@property (nullable, nonatomic, strong) NSString *username

Declared In

MLIMUser.h

  phoneNumber

The user’s phone number.

@property (nullable, nonatomic, strong) NSString *phoneNumber

Declared In

MLIMUser.h

  updatedAt

The last time user updated

@property (nullable, nonatomic, readonly) NSDate *updatedAt

Declared In

MLIMUser.h

  sessionCount

The number of user logged in client.

@property (nonatomic, readonly) NSInteger sessionCount

Declared In

MLIMUser.h

  attributes

Custom attributes for the user.

@property (nullable, nonatomic, strong) NSDictionary *attributes

Declared In

MLIMUser.h

  online

Online status of the user

@property (nonatomic) BOOL online

Declared In

MLIMUser.h

  friends

Friends of the user.

@property (nonatomic, readonly) NSArray<MLIMRelationInfo*> *friends

Declared In

MLIMUser.h

  groups

Groups of the user.

@property (nonatomic, readonly) NSArray<MLIMGroup*> *groups

Declared In

MLIMUser.h

  rooms

Rooms of the user.

@property (nonatomic, readonly) NSArray<MLIMRoom*> *rooms

Declared In

MLIMUser.h

+ userWithId:

Create user object with userID.

+ (instancetype)userWithId:(NSString *)uid

Parameters

uid

The userId, the userId should match [a-zA-Z0-9_\-]+.

Return Value

a MLIMUser object.

Declared In

MLIMUser.h

– fetchWithCompletion:

Fetch the user data, including user’s friendIds, groupIds and roomIds.

- (void)fetchWithCompletion:(MLIMBooleanResultBlock)block

Parameters

block

A block to be executed after request completion.

Declared In

MLIMUser.h

– fetchFriendsWithDetail:completion:

Fetch friend info. The friend’s info will be saved in user.friends property.

- (void)fetchFriendsWithDetail:(BOOL)detail completion:(MLIMBooleanResultBlock)block

Parameters

detail

Should get friend detail info or not. If NO, only friend ID will be retured.

block

A block to be executed after request completion.

Declared In

MLIMUser.h

– addFriendWithUser:completion:

Add a friend with userId.

- (void)addFriendWithUser:(NSString *)uid completion:(void ( ^ ) ( NSDictionary *result , NSError *_Nullable error ))block

Parameters

uid

The friend’s uid.

block

A block to be executed after request completion.

Declared In

MLIMUser.h

– addFriend:completion:

Add a friend with userId.

- (void)addFriend:(NSString *)uid completion:(void ( ^ ) ( NSDictionary *result , NSError *_Nullable error ))block

Parameters

uid

The friend’s uid.

block

A block to be executed after request completion.

Declared In

MLIMUser.h

– batchAddFriends:completion:

Batch add friends

- (void)batchAddFriends:(NSArray *)ids completion:(void ( ^ ) ( NSArray<NSDictionary*> *result , NSError *_Nullable error ))block

Parameters

ids

friend user ids

block

A block to be executed after request completion.

Declared In

MLIMUser.h

– getFriendInfo:completion:

Get the friend detail with friend uid.

- (void)getFriendInfo:(NSString *)friendId completion:(void ( ^ ) ( MLIMRelationInfo *, NSError *_Nullable ))block

Parameters

friendId

The friend userId.

block

A block to be executed after request completion.

Declared In

MLIMUser.h

– deleteFriend:completion:

Remove a friend with friend’s userId.

- (void)deleteFriend:(NSString *)uid completion:(MLIMBooleanResultBlock)block

Parameters

uid

The friend’s userId.

block

A block to be executed after request completion.

Declared In

MLIMUser.h

– getLatestChatsWithFriend:beforeTimestamp:limit:block:

Get the latest messages chat with friend.

- (void)getLatestChatsWithFriend:(NSString *)uid beforeTimestamp:(NSTimeInterval)ts limit:(int)limit block:(void ( ^ ) ( NSArray<MLIMMessage*> *_Nullable messages , NSError *_Nullable error ))block

Parameters

uid

The friend userId.

ts

The time

limit

The limit on number of messages to return.

block

A block to be executed after reuqest completion.

Declared In

MLIMUser.h

– hideChatsWithFriend:before:block:

Hide the messages before a timestamp

- (void)hideChatsWithFriend:(NSString *)uid before:(NSTimeInterval)before block:(MLIMBooleanResultBlock)block

Parameters

uid

The friend id

before

before this timestamp

block

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

Declared In

MLIMUser.h

– fetchStrangersWithDetail:params:completion:

Fetch stranger list that the user have contacted with. The list can be retrieved from user.strangers property later.

- (void)fetchStrangersWithDetail:(BOOL)detail params:(nullable NSDictionary<NSString*,NSString*> *)params completion:(void ( ^ ) ( NSArray<MLIMRelationInfo*> *_Nullable result , NSError *_Nullable error ))block

Parameters

detail

If true, stranger detail information will be returned, otherwise only stranger id will be re

params

{“limit”:“10”, “skip”:“0”, “ids”:“id1,id2,id3”}

block

A block to be executed after reuqest completion.

Declared In

MLIMUser.h

– getInfoOfStranger:completion:

Get the detail stranger info

- (void)getInfoOfStranger:(NSString *)strangerId completion:(void ( ^ ) ( MLIMRelationInfo *, NSError *_Nullable ))block

Parameters

strangerId

the stranger userId

block

A block to be executed after reuqest completion.

Declared In

MLIMUser.h

– getLatestChatsWithStranger:before:limit:block:

Get the latest message chat with the stranger

- (void)getLatestChatsWithStranger:(NSString *)uid before:(NSTimeInterval)ts limit:(int)limit block:(void ( ^ ) ( NSArray<MLIMMessage*> *_Nullable messages , NSError *_Nullable error ))block

Parameters

uid

the stranger userId

ts

the time

limit

the limit on number of messages to return

block

A block to be executed after reuqest completion.

Declared In

MLIMUser.h

– hideChatsWithStranger:before:block:

Hide the history messages with a stranger.

- (void)hideChatsWithStranger:(NSString *)uid before:(NSTimeInterval)before block:(MLIMBooleanResultBlock)block

Parameters

uid

The stranger id

before

hide messages before this timestamp

block

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

Declared In

MLIMUser.h

– fetchGroupsWithDetail:completion:

Fetch user’s group list. The group’s info will be saved in user.groups property.

- (void)fetchGroupsWithDetail:(BOOL)detail completion:(MLIMBooleanResultBlock)block

Parameters

detail

Should get group detail info or not. If NO, only group ID will be retured.

block

A block to be executed after request completion.

Declared In

MLIMUser.h

– fetchRoomsWithDetail:completion:

Fetch room info. The room’s info will be saved in user.rooms property.

- (void)fetchRoomsWithDetail:(BOOL)detail completion:(MLIMBooleanResultBlock)block

Parameters

detail

Should get room detail info or not. If NO, only room ID will be retured.

block

A block to be executed after request completion.

Declared In

MLIMUser.h

– updateAttributes:completion:

Update user attributes. The attributes keys must be a string, the values can be any json serializable type.

- (void)updateAttributes:(NSDictionary<NSString*,id> *)attrs completion:(MLIMBooleanResultBlock)block

Parameters

attrs

the custom user attributes

block

A block to return the result.

Declared In

MLIMUser.h

– replaceAttributes:completion:

Replace whole attributes with the new one. The attributes keys must be a string, the values can be any json serializable type.

- (void)replaceAttributes:(NSDictionary<NSString*,id> *)attrs completion:(MLIMBooleanResultBlock)block

Parameters

attrs

the custom user attributes

block

A block to return the result.

Declared In

MLIMUser.h

– fetchAttributesWithCompletion:

Fetch the attributes.

- (void)fetchAttributesWithCompletion:(void ( ^ ) ( NSDictionary *_Nullable attrs , NSError *_Nullable error ))block

Parameters

block

A block to return the result.

Declared In

MLIMUser.h

– getAttributeForKey:completion:

Get one attribute with key.

- (void)getAttributeForKey:(NSString *)key completion:(void ( ^ ) ( id _Nullable value , NSError *_Nullable error ))block

Parameters

key

attribute name

block

A block to return the result.

Declared In

MLIMUser.h

– deleteAttributesWithCompletion:

Delete the whole attributes.

- (void)deleteAttributesWithCompletion:(MLIMBooleanResultBlock)block

Parameters

block

A block to return the result.

Declared In

MLIMUser.h

– fetchAttributesForGroup:completion:

Fetch user attributes defined for a group.

- (void)fetchAttributesForGroup:(NSString *)groupId completion:(void ( ^ ) ( NSDictionary *_Nullable attrs , NSError *_Nullable error ))block

Parameters

groupId

The group id

block

A block to return the result. It should have the following argument signature:(NSDictionary *, NSError)

Declared In

MLIMUser.h

– updateAttributes:forGroup:completion:

Update some user attributes in a group.

- (void)updateAttributes:(NSDictionary<NSString*,id> *)attrs forGroup:(NSString *)groupId completion:(MLIMBooleanResultBlock)block

Parameters

attrs

The new attributes, attributes not in the dictionary will not be changed.

groupId

The group id

block

A block to return the result.

Declared In

MLIMUser.h

– replaceAttributes:forGroup:completion:

Replace user attributes for a group.

- (void)replaceAttributes:(NSDictionary<NSString*,id> *)attrs forGroup:(NSString *)groupId completion:(MLIMBooleanResultBlock)block

Parameters

attrs

The new attributes to replace the old one.

groupId

The group id.

block

A block to return the result.

Declared In

MLIMUser.h

– deleteAttributesForGroup:completion:

Delete all the user attributes for a group.

- (void)deleteAttributesForGroup:(NSString *)groupId completion:(MLIMBooleanResultBlock)block

Parameters

groupId

The group id

block

A block to return the result.

Declared In

MLIMUser.h

– fetchAttributesForRoom:completion:

Fetch user attributes defined for a room.

- (void)fetchAttributesForRoom:(NSString *)roomId completion:(void ( ^ ) ( NSDictionary *_Nullable attrs , NSError *_Nullable error ))block

Parameters

roomId

The room id

block

A block to return the result.

Declared In

MLIMUser.h

– updateAttributes:forRoom:completion:

Update some user attributes in a room. The attributes which are not in the new attrs dictionary will not be changed.

- (void)updateAttributes:(NSDictionary<NSString*,id> *)attrs forRoom:(NSString *)roomId completion:(MLIMBooleanResultBlock)block

Parameters

attrs

The new attributes

roomId

The room id

block

A block to return the result.

Declared In

MLIMUser.h

– replaceAttributes:forRoom:completion:

Replace user attributes map for a room with the new one.

- (void)replaceAttributes:(NSDictionary<NSString*,id> *)attrs forRoom:(NSString *)roomId completion:(MLIMBooleanResultBlock)block

Parameters

attrs

The new attributes to replace the old one.

roomId

The room id

block

A block to return the result.

Declared In

MLIMUser.h

– deleteAttributesForRoom:completion:

Delete the user attributes for a room

- (void)deleteAttributesForRoom:(NSString *)roomId completion:(MLIMBooleanResultBlock)block

Parameters

roomId

The room id

block

A block to return the result.

Declared In

MLIMUser.h