MaxSocialUser Class Reference

Inherits from NSObject
Declared in MaxSocialUser.h

Overview

A MaxSocialUser represents a user persisted to the MaxSocial.

Properties

  userId

An opaque value that represents a user in your user system.

@property (nonatomic, strong) NSString *userId

Declared In

MaxSocialUser.h

  username

The username of the user.

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

Declared In

MaxSocialUser.h

Constructors

+ userWithId:

Create a MaxSocialUser object using the opaque user id.

+ (instancetype)userWithId:(NSString *)userId

Parameters

userId

The opaque user id that represents a user in your user system.

Return Value

A new MaxSocialUser object.

Declared In

MaxSocialUser.h

Relation

– followUser:block:

Follow the user which has an id userId. The method calls followUser:reverse:block: by passing reverse NO.

- (void)followUser:(NSString *)userId block:(MLArrayResultBlock)block

Parameters

userId

The followee’s id.

block

A block to return the follow operation result. The block should have the following signatures: (NSArray<NSDictionary> array, NSError *error)

Discussion

The user following relation was maintained by a MaxSocialRelationInfo object. Following a user will create or update the relation object. And the callback will return the following results:

@code // on creation [ {“createdAt”:“2016-04-08T03:06:19.911Z”,“objectId”:“5707202b238c8f00018dd535”}, {} ]

// on updating [ {“updateResult”:1}, {} ] @endcode

Declared In

MaxSocialUser.h

– followUser:reverse:block:

Follow the user which has an id userId.

- (void)followUser:(NSString *)userId reverse:(BOOL)reverse block:(MLArrayResultBlock)block

Parameters

userId

The followee’s id.

reverse

Whether follow each other.

block

A block to return the follow operation result. The block should have the following signatures: (NSArray<NSDictionary> array, NSError *error)

Discussion

The user following relation was maintained by a MaxSocialRelationInfo object. Following a user will create or update the relation object. And the callback will return the following results:

@code // on creation [ {“createdAt”:“2016-04-08T03:06:19.911Z”,“objectId”:“5707202b238c8f00018dd535”}, // if reverse is NO, the following dictionary will be empty {“createdAt”:“2016-04-08T03:06:19.911Z”,“objectId”:“5707202b238c8f00018dd535”} ]

// on updating [ {“updateResult”:1}, {“updateResult”:1} ] @endcode

Declared In

MaxSocialUser.h

– unfollowUser:block:

Unfollow the user which has an id userId.

- (void)unfollowUser:(NSString *)userId block:(MLBooleanResultBlock)block

Parameters

userId

The followee’s id.

block

A block to return the unfollow operation result. The block should have the following signatures: (BOOL succeeded, NSError *error)

Declared In

MaxSocialUser.h

– blockUser:completion:

Block a follower. Followers were blocked cannot read your shuoshuos.

- (void)blockUser:(NSString *)userId completion:(MLBooleanResultBlock)completion

Parameters

userId

The follower’s id to block.

completion

A block to return the operation result. The block should have the following signatures: (BOOL succeeded, NSError *error)

Declared In

MaxSocialUser.h

– unblockUser:completion:

Unblock a follower. Followers were blocked cannot read your shuoshuos.

- (void)unblockUser:(NSString *)userId completion:(MLBooleanResultBlock)completion

Parameters

userId

The follower’s id to unblock.

completion

A block to return the operation result. The block should have the following signatures: (BOOL succeeded, NSError *error)

Declared In

MaxSocialUser.h

– getRelationInfoWithId:block:

Retrieve the MaxSocialRelationInfo object with objectId.

- (void)getRelationInfoWithId:(NSString *)objectId block:(MLSRelationResultBlock)block

Parameters

objectId

The relation info object’s objectId.

block

A block to return the result. The block should have the following signatures: (MaxSocialRelationInfo relation, NSError error)

Declared In

MaxSocialUser.h

– getRelationInfoWithUserId:followerId:block:

Retrieve the MaxSocialRelationInfo object by userId and followerId.

- (void)getRelationInfoWithUserId:(NSString *)userId followerId:(NSString *)followerId block:(MLSRelationResultBlock)block

Parameters

userId

The followee id.

followerId

The follower id.

block

A block to return the result. The block should have the following signatures: (MaxSocialRelationInfo relation, NSError error)

Declared In

MaxSocialUser.h

– deleteRelationInfoWithId:block:

Delete the relation info object by id.

- (void)deleteRelationInfoWithId:(NSString *)relationInfoId block:(MLBooleanResultBlock)block

Parameters

relationInfoId

The relation info object’s objectId.

block

A block to return the result. The block should have the following signatures: (BOOL succeeded, NSError *error)

Declared In

MaxSocialUser.h

+ queryWhetherUser:isFollowingUser:resultBlock:

Query the relation between userId and anotherUserId.

+ (void)queryWhetherUser:(NSString *)userId isFollowingUser:(NSString *)anotherUserId resultBlock:(void ( ^ ) ( BOOL isFollowing , BOOL isReverse , NSError *error ))block

Parameters

userId

The follower id.

anotherUserId

The followee id.

block

A block to return the result. The block has 3 parameters: isFollowing indicates whether the userId is following the anotherUserId; isReverse indicates whether the anotherUserId is following userId at the same time; error represents any error occured while performing the request.

Declared In

MaxSocialUser.h

– getFolloweesWithQuery:block:

Retrieve the followee list with a query object.

- (void)getFolloweesWithQuery:(MaxSocialQuery *)query block:(MLArrayResultBlock)block

Parameters

query

A max social query object.

block

A block to return the result. The block should have the following signatures: (NSArrayMaxSocialRelationInfo> followees, NSError *error)

Declared In

MaxSocialUser.h

– getFollowersWithQuery:block:

Retrieve the follower list with a query object.

- (void)getFollowersWithQuery:(MaxSocialQuery *)query block:(MLArrayResultBlock)block

Parameters

query

A max social query object.

block

A block to return the result. The block should have the following signatures: (NSArrayMaxSocialRelationInfo> followers, NSError *error)

Declared In

MaxSocialUser.h

Shuoshuo

– postShuoShuo:toSquare:block:

Post a new shuoshuo.

- (void)postShuoShuo:(MaxSocialShuoShuo *)shuoshuo toSquare:(BOOL)toSquare block:(MLBooleanResultBlock)block

Parameters

shuoshuo

The shuoshuo object.

toSquare

Whether post the shuoshuo to the square. If NO, the shuoshuo will not appear in shuoshuo square.

block

A block to return the result. The block should have the following signatures: (BOOL succeeded, NSError *error)

Declared In

MaxSocialUser.h

– getShuoShuoWithQuery:block:

List user’s own shuoshuo.

- (void)getShuoShuoWithQuery:(MaxSocialQuery *)query block:(MLDictionaryResultBlock)block

Parameters

query

The query object.

block

A block to return the result. The block should have the following signatures: (NSDictionary result, NSError error)

Discussion

The result have the following structure: @code { “shuoshuos”:[ … MaxSocialShuoShuo objects> … ], “comments” :{ “shuoshuoId” : [ … … ], … }, “zans” :{ “shuoshuoId” : [ … … ], … }, } @endcode

Declared In

MaxSocialUser.h

– getLatestShuoShuoInSquareWithQuery:block:

Query shuoshuos posted in the square.

- (void)getLatestShuoShuoInSquareWithQuery:(MaxSocialQuery *)query block:(MLDictionaryResultBlock)block

Parameters

query

The query object.

block

A block to return the result. The block should have the following signatures: (NSDictionary result, NSError error)

Discussion

The result have the following structure: @code { “shuoshuos”:[ … MaxSocialShuoShuo objects> … ], “comments” :{ “shuoshuoId” : [ … … ], … }, “zans” :{ “shuoshuoId” : [ … … ], … }, } @endcode

Declared In

MaxSocialUser.h

– getLatestShuoShuoInFriendCycleWithQuery:block:

Query shuoshuos posted by user’s followees.

- (void)getLatestShuoShuoInFriendCycleWithQuery:(MaxSocialQuery *)query block:(MLDictionaryResultBlock)block

Parameters

query

The query object.

block

A block to return the result. The block should have the following signatures: (NSDictionary result, NSError error)

Discussion

The result have the following structure: @code { “shuoshuos”:[ … MaxSocialShuoShuo objects> … ], “comments” :{ “shuoshuoId” : [ … … ], … }, “zans” :{ “shuoshuoId” : [ … … ], … }, } @endcode

Declared In

MaxSocialUser.h

– getShuoShuoNearLocation:distance:block:

Query shuoshuos near the location.

- (void)getShuoShuoNearLocation:(MaxSocialLocation *)location distance:(int64_t)distance block:(MLDictionaryResultBlock)block

Parameters

location

The reference location

distance

Max distance

block

A block to return the result. The block should have the following signatures: (NSDictionary result, NSError error)

Discussion

The result have the following structure: @code { “shuoshuos”:[ … MaxSocialShuoShuo objects> … ], “comments” :{ “shuoshuoId” : [ … … ], … }, “zans” :{ “shuoshuoId” : [ … … ], … }, } @endcode

Declared In

MaxSocialUser.h

– getImageNamesOfShuoShuo:block:

Retrieve the image names of a shuoshuo.

- (void)getImageNamesOfShuoShuo:(NSString *)shuoId block:(MLArrayResultBlock)block

Parameters

shuoId

The shuoshuo’s objectId.

block

A block to return the result. The block should have the following signatures: (NSArray<NSString> imageNames, NSError *error)

Discussion

The image name is an opaque string that represents an image. It’s NOT a URI. The image can be download by calling downloadImageWithName:ofShuoShuo:progress:completion:.

Declared In

MaxSocialUser.h

– downloadImageWithName:ofShuoShuo:progress:completion:

Download the shuoshuo image by the given opaque image name.

- (void)downloadImageWithName:(NSString *)imageName ofShuoShuo:(NSString *)shuoId progress:(nullable MLProgressBlock)progress completion:(nullable MLStringResultBlock)completion

Parameters

imageName

An opaque string that represents an shuoshuo image.

shuoId

The shuoshuo objectId.

progress

A block to notify the image downloading progress. It should have the following signatures: (int percentDone)

completion

A block to return the result. It should have the following signatures: (NSString downloadedImagePath, NSError error)

Declared In

MaxSocialUser.h

– fetchShuoShuoWithId:block:

Retrieve a shuoshuo object with shuoshuoId.

- (void)fetchShuoShuoWithId:(NSString *)shuoId block:(MLSShuoShuoResultBlock)block

Parameters

shuoId

The shuoshuo’s objectId.

block

A block to return the shuoshuo object. It should have the following signatures: (MaxSocialShuoShuo status, NSError error)

Declared In

MaxSocialUser.h

– deleteShuoShuoWithId:block:

Delete a shuoshuo by shuoshuoId. This also remove all photos related to the shuoshuo.

- (void)deleteShuoShuoWithId:(NSString *)shuoId block:(void ( ^ ) ( BOOL shuoDelete , BOOL photosDelete , NSError *_Nullable error ))block

Parameters

shuoId

The shuoshuo’s objectId.

block

A block to return the result. It should have the following signatures: (BOOL shuoDelete, BOOL photosDelete, NSError *error)

Declared In

MaxSocialUser.h

Location

– updateLocation:block:

Update the user’s location.

- (void)updateLocation:(MaxSocialLocation *)location block:(MLBooleanResultBlock)block

Parameters

location

A object that represents the user’s location.

block

A block to return the result. It should have the following signatures: (BOOL succeeded, NSError *error)

Declared In

MaxSocialUser.h

– queryUserNearLocation:distance:block:

Find people near location. UserIds can be retrieved by reading locationInfo.userId.

- (void)queryUserNearLocation:(MaxSocialLocation *)location distance:(int64_t)distance block:(MLArrayResultBlock)block

Parameters

location

A location

distance

The radius

block

The result callback. It should have the following signatures: (NSArray<MaxSocialLocationInfo> locationInfoList, NSError *error)

Declared In

MaxSocialUser.h

– getLocationInfoWithBlock:

Retrieve user’s location.

- (void)getLocationInfoWithBlock:(MLSLocationResultBlock)block

Parameters

block

The result callback. It should have the following signatures: (MaxSocialLocationInfo locationInfo, NSError error)

Declared In

MaxSocialUser.h

– fetchLocationInfoWithObjectId:block:

Retrieve location info object by objectId.

- (void)fetchLocationInfoWithObjectId:(NSString *)objectId block:(MLSLocationResultBlock)block

Parameters

objectId

The location info objectId.

block

The result callback. It should have the following signatures: (MaxSocialLocationInfo locationInfo, NSError error)

Declared In

MaxSocialUser.h

– deleteLocationInfoWithObjectId:block:

Delete location info object by objectId.

- (void)deleteLocationInfoWithObjectId:(NSString *)objectId block:(MLBooleanResultBlock)block

Parameters

objectId

The lcoation info objectId.

block

The callback. It should have the following signatures: (BOOL succeeded, NSError *error)

Declared In

MaxSocialUser.h

Comment

– createOrUpdateComment:block:

Create a comment for a shuoshuo.

- (void)createOrUpdateComment:(NSDictionary *)params block:(MLSCommentResultBlock)block

Parameters

params

The comment parameters.

block

The result callback. It should have the following signatures: (MaxSocialComment comment, NSError error)

Discussion

The valid params structure is: @code { “objectId”: “8941b1863330920045fea193”, // if objectId is set, excute update operation “userId”: “5641b10b3330920001f1f7a4”, “shuoId”: “570613bf6b85b3436e86aa43”, “content”: “just test!”, “zan”: false, // if true, the content MUST NOT be set! “read”: false, “friendCircle”: true, “toUserId”: “5641b10b3330920001f1f7a4”, “hostUserId”: “5641b10b3330920001f1f7a4” } @endcode

CREATE A TEXT COMMEMT: @code { “userId”: “5641b10b3330920001f1f7a4”, “shuoId”: “570613bf6b85b3436e86aa43”, “content”: “just test!”, “zan”: false, // if true, the content must not be set! “friendCircle”: true, “toUserId”: “5641b10b3330920001f1f7a4”, “hostUserId”: “5641b10b3330920001f1f7a4” } @endcode

CREATE A ZAN: @code { “userId”: “5641b10b3330920001f1f7a4”, “shuoId”: “570613bf6b85b3436e86aa43”, “zan”: true, “friendCircle”: true, “toUserId”: “5641b10b3330920001f1f7a4”, “hostUserId”: “5641b10b3330920001f1f7a4” } @endcode

MARK A COMMENT AS READ: @code { “objectId”: “8941b1863330920045fea193”, “read”: false } @endcode

Declared In

MaxSocialUser.h

– batchUpdateComments:block:

Batch update comments

- (void)batchUpdateComments:(NSArray<NSDictionary*> *)updates block:(MLBooleanResultBlock)block

Parameters

updates

The parameters

block

The callback. It should have the following signatures: (BOOL succeeded, NSError *error)

Discussion

The valid stucture of params is: @code [ { “objectId” : comment.objectId, “read” : true }, … ] @endcode

Declared In

MaxSocialUser.h

– createCommentForShuoShuo:withContent:block:

Create a comment for a shuoshuo.

- (void)createCommentForShuoShuo:(NSString *)shuoId withContent:(NSString *)text block:(MLSCommentResultBlock)block

Parameters

shuoId

The id of shuoshuo to comment.

text

The content of the comment.

block

The result callback. It should have the following signatures: (MaxSocialComment comment, NSError error)

Declared In

MaxSocialUser.h

– markCommentAsRead:completion:

Mark a comment as read.

- (void)markCommentAsRead:(NSString *)commentId completion:(void ( ^ ) ( BOOL updated , NSError *_Nullable error ))block

Parameters

commentId

The id of comment.

block

The result callback. It should have the following signatures: (BOOL updated, NSError *error)

Declared In

MaxSocialUser.h

– likeShuoShuo:block:

Like a shuoshuo. This operation creates a comment without content.

- (void)likeShuoShuo:(NSString *)shuoId block:(MLSCommentResultBlock)block

Parameters

shuoId

The shuoshuoId

block

The result callback. It should have the following signatures: (MaxSocialComment comment, NSError error)

Declared In

MaxSocialUser.h

– getCommentWithId:block:

Retrieve a comment object with commentId.

- (void)getCommentWithId:(NSString *)commentId block:(MLSCommentResultBlock)block

Parameters

commentId

The comment’s objectId.

block

The result callback. It should have the following signatures: (MaxSocialComment comment, NSError error)

Declared In

MaxSocialUser.h

– deleteCommentWithId:block:

Delete a comment by comentId.

- (void)deleteCommentWithId:(NSString *)commentId block:(MLBooleanResultBlock)block

Parameters

commentId

The comment’s objectId.

block

The result callback. It should have the following signatures: (BOOL succeeded, NSError *error)

Declared In

MaxSocialUser.h

– getCommentOfShuoshuo:withQuery:block:

Retrieve comments of a shuoshuo. The query object can be used to restrict the number of comments to return, and the order of comments.

- (void)getCommentOfShuoshuo:(NSString *)shuoId withQuery:(MaxSocialQuery *)query block:(MLArrayResultBlock)block

Parameters

shuoId

The shuoshuoId

query

A query object

block

The result block. It should have the following signatures: (NSArray<MaxSocialComment> comments, NSError *error)

Declared In

MaxSocialUser.h

– getUnreadCommentWithBlock:

Retrieve user’s unread comments.

- (void)getUnreadCommentWithBlock:(MLArrayResultBlock)block

Parameters

block

The result block. It should have the following signatures: (NSArray<MaxSocialComment> comments, NSError *error)

Declared In

MaxSocialUser.h

– getUnreadCommentWithParams:block:

Retrieve user’s unread comments.

- (void)getUnreadCommentWithParams:(NSDictionary *)params block:(MLDictionaryResultBlock)block

Parameters

params

The filter parameters, userId(default is self.userId), toUserId, hostUserId

block

The result block. It should have the following signatures: (NSDictionary results, NSError error)

Declared In

MaxSocialUser.h

+ registerWithUsername:password:completion:

Register a new user.

+ (void)registerWithUsername:(NSString *)username password:(NSString *)password completion:(MLIdResultBlock)block

Parameters

username

The new user’s username

password

The password

block

A block to return the registration result.

Declared In

MaxSocialUser.h

+ loginWithUsername:password:completion:

Login with username and password.

+ (void)loginWithUsername:(NSString *)username password:(NSString *)password completion:(MLIdResultBlock)block

Parameters

username

The username

password

The password

block

A block to return the login result.

Declared In

MaxSocialUser.h

+ requestSmscodeWithPhoneNumber:completion:

Request a smscode which can be used to login.

+ (void)requestSmscodeWithPhoneNumber:(NSString *)phoneNumber completion:(MLIdResultBlock)block

Parameters

phoneNumber

A phone number

block

A block to return the result: whether the smsCode send successully or not.

Declared In

MaxSocialUser.h

+ loginWithPhoneNumber:smsCode:completion:

Login with a phone number and the sms code.

+ (void)loginWithPhoneNumber:(NSString *)phoneNumber smsCode:(NSString *)smsCode completion:(MLIdResultBlock)block

Parameters

phoneNumber

A phone number

smsCode

The smsCode

block

A block to return the login result.

Declared In

MaxSocialUser.h