MLIMGroup Class Reference

Inherits from MLIMRuntimeObject : NSObject
Declared in MLIMGroup.h

Overview

The representation of a group.

Properties

  groupId

The group ID.

@property (nonatomic, readonly) NSString *groupId

Declared In

MLIMGroup.h

  owner

The group’s owner.

@property (nonatomic, strong) NSString *owner

Declared In

MLIMGroup.h

  name

The group’s name.

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

Declared In

MLIMGroup.h

  members

The userIds of group member.

@property (nonatomic, readonly) NSArray<NSString*> *members

Declared In

MLIMGroup.h

  attributes

The custom attributes

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

Declared In

MLIMGroup.h

  recentMessage

The recent message

@property (nullable, nonatomic, readonly) MLIMMessage *recentMessage

Declared In

MLIMGroup.h

Creating `MLIMGroup` instances

+ groupWithId:

Creates a group object with groupId.

+ (instancetype)groupWithId:(NSString *)gid

Parameters

gid

The groupId.

Return Value

A group object without group metadata.

Declared In

MLIMGroup.h

+ groupWithDictionary:

Creates a group object with group payload dictionary.

+ (instancetype)groupWithDictionary:(NSDictionary *)dictionary

Parameters

dictionary

The group payload dictionary.

Return Value

A group object.

Declared In

MLIMGroup.h

Creates Groups

+ createWithOwner:name:members:block:

Creates a group.

+ (void)createWithOwner:(NSString *)owner name:(NSString *)name members:(nullable NSArray *)members block:(void ( ^ ) ( MLIMGroup *group , NSError *error ))block

Parameters

owner

The group owner

name

The group name

members

The group members

block

A block to be executed after creation complete. The block should have the following signature: (MLIMGroup group, NSError error)

Declared In

MLIMGroup.h

Fetch data of a group.

– fetchWithBlock:

Fetch the group info.

- (void)fetchWithBlock:(MLIMBooleanResultBlock)block

Parameters

block

A block to be executed after creation complete. The block should have the following signature: (BOOL succeeded, NSError *error)

Declared In

MLIMGroup.h

– getLatestMessagesBefore:limit:completion:

Get limit group messages before time.

- (void)getLatestMessagesBefore:(NSTimeInterval)time limit:(int)limit completion:(void ( ^ ) ( NSArray<MLIMMessage*> *_Nullable messages , NSError *_Nullable error ))block

Parameters

time

The timestamp

limit

A limit on the number of messages to return. The default limit is 20.

block

A block to be executed after get the messages.

Declared In

MLIMGroup.h

– getLatestMessagesForUser:before:limit:completion:

Get group messages for a member.

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

Parameters

uid

The member’s id

time

A timestamp

limit

A limit on the number of messages to return. The default limit is 20.

block

A block to be executed after get the messages.

Declared In

MLIMGroup.h

– hideHistoryMessagesBefore:forUser:block:

Hide the history messages for one group member.

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

Parameters

before

Before the timestamp

uid

The member id

block

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

Declared In

MLIMGroup.h

Update group.

– changeOwner:block:

Change the owner of the group.

- (void)changeOwner:(NSString *)newOwner block:(MLIMBooleanResultBlock)block

Parameters

newOwner

The userId of new owner.

block

A block to notify the result.

Declared In

MLIMGroup.h

– addAMember:block:

Add one member to the group.

- (void)addAMember:(NSString *)mem block:(void ( ^ ) ( BOOL , NSError *__Nullable ))block

Parameters

mem

Id of the new member

block

A block to be executed after member add completion.

Declared In

MLIMGroup.h

– addMembers:block:

Add members to the group.

- (void)addMembers:(NSArray *)newMembers block:(MLIMBooleanResultBlock)block

Parameters

newMembers

The new members to add.

block

A block to be executed after member add completion.

Declared In

MLIMGroup.h

– removeAMember:block:

Remove a member from the group.

- (void)removeAMember:(NSString *)mem block:(void ( ^ ) ( BOOL , NSError *__Nullable ))block

Parameters

mem

Id of the member to remove.

block

A block to be executed after member remove completion.

Declared In

MLIMGroup.h

– removeMembers:block:

Remove members from the group. The group owner cannot be removed.

- (void)removeMembers:(NSArray *)members block:(MLIMBooleanResultBlock)block

Parameters

members

The members to remove.

block

A block to be executed after member remove completion.

Declared In

MLIMGroup.h

– overwriteMembers:block:

Replace all group members except the owner with newMembers.

- (void)overwriteMembers:(NSArray *)newMembers block:(MLIMBooleanResultBlock)block

Parameters

newMembers

New members for the group.

block

A block to be executed after member replace completion.

Declared In

MLIMGroup.h

Delete Groups

– deleteWithBlock:

Delete the group.

- (void)deleteWithBlock:(MLIMBooleanResultBlock)block

Parameters

block

A block to be execute after group delete completion.

Declared In

MLIMGroup.h

Group Attributes

– 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:(void ( ^ ) ( BOOL success , NSError *_Nullable error ))block

Parameters

attrs

the custom user attributes

block

A block to return the result.

Declared In

MLIMGroup.h

– updateName:block:

Update the name field of group attributes.

- (void)updateName:(NSString *)name block:(MLIMBooleanResultBlock)block

Parameters

name

The new group name.

block

A block to be executed after update completion.

Declared In

MLIMGroup.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:(void ( ^ ) ( BOOL success , NSError *_Nullable error ))block

Parameters

attrs

the custom user attributes

block

A block to return the result.

Declared In

MLIMGroup.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

MLIMGroup.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

MLIMGroup.h

– deleteAttributesWithCompletion:

Delete the whole attributes.

- (void)deleteAttributesWithCompletion:(void ( ^ ) ( BOOL success , NSError *_Nullable error ))block

Parameters

block

A block to return the result.

Declared In

MLIMGroup.h