Coder Social home page Coder Social logo

onochat-iossdk's Introduction

ONOChat

  • 简易快速集成稳定分布式IM

CI Status Version License Platform

对外提供接口的类 <ONOIMClient.h>

@interface ONOIMClient : NSObject

/**
 *  设置聊天服务器参数
 *
 *  @param host    帐号
 *  @param port    端口号
 */
- (void)setupGateHost:(NSString*)host port:(int)port;


/**
 *  登录
 *
 *  @param token      令牌 (在后台绑定的登录token)
 */
- (void)loginWithToken:(NSString *)token onSuccess:(void(^)(ONOUser *user))successBlock onError:(void(^)(int errorCode, NSString *errorMsg))errorBlock;

/**
 *  退出登录
 *
 */
- (void)logout;



/**
 *  发送消息
 *
 *  @param message   要发送的消息
 *  @param targetId    目标ID
 */

- (void)sendMessage:(ONOMessage *)message to:(NSString *)targetId onSuccess:(void (^)(NSString *messageId))successBlock onError:(void (^)(int errorCode, NSString *errorMessage))errorBlock;

/**
 *  获取会话列表
 */
- (NSArray <ONOConversation *>*)getConversationList;

/**
 *  获取单个会话信息
 *  @param userId    目标用户ID
 */
- (ONOConversation *)getConversation:(NSString *)userId;

/**
 *  获取消息列表
 */
- (NSArray <ONOMessage *>*)getMessageList:(NSString *)targetId offset:(NSString *)offset limit:(int)limit;

/**
 *  获取未读消息数目
 */
- (int)totalUnreadCount;

/**
 *  清空指定会话的未读消息数
 *  @param targetId    会话id
 */
- (void)clearConversationUnread:(NSString *)targetId;

- (ONOMessage *)createMessageByType:(int)type;


/**
 *  获取用户信息
 *  @param userId    会话id
 */
- (void)userProfile:(NSString *)userId onSuccess:(void (^)(ONOUser *user))successBlock onError:(void (^)(int errorCode, NSString *errorMessage))errorBlock;
- (void)userProfile:(NSString *)userId withCache:(BOOL)withCache onSuccess:(void (^)(ONOUser *user))successBlock onError:(void (^)(int errorCode, NSString *errorMessage))errorBlock;
- (void)userProfiles:(NSArray<NSString*> *)userIds onSuccess:(void (^)(NSArray<ONOUser *> *users))successBlock onError:(void (^)(int errorCode, NSString *errorMessage))errorBlock;

// 好友

/**
 *  获取 好友列表(从本地获取)
 */
- (NSArray <ONOUser *>*)getFriends;


/**
 *  好友模糊搜索
 *  @param keyword    搜索关键字
 */
- (void)friendSearchByKeyword:(NSString *)keyword onSuccess:(void (^)(NSArray<ONOUser *> *userArray))successBlock onError:(void (^)(int errorCode, NSString *errorMessage))errorBlock;

/**
 *  好友添加
 *  @param userId       添加好友的id
 *  @param greeting    添加好友的问候语
 */
- (void)friendAddWithUserId:(NSString *)userId andGreeting:(NSString *)greeting onSuccess:(void (^)(void))successBlock onError:(void (^)(int errorCode, NSString *errorMessage))errorBlock;

/**
 *  好友添加请求列表(offset时间点以前的请求列表)
 *  @param limit       条数
 *  @param offset    分页之前的最一条的createdAt
 */
- (void)friendRequestListWithLimit:(int)limit andOffset:(NSString *)offset onSuccess:(void (^)(NSArray<ONOFriendRequest *> *friendRequest))successBlock onError:(void (^)(int errorCode, NSString *errorMessage))errorBlock;

/**
 *  好友添加请求 -> 通过
 *  @param userId       添加请求好友的id
 */
- (void)friendAgreeWithUserId:(NSString *)userId onSuccess:(void (^)(void))successBlock onError:(void (^)(int errorCode, NSString *errorMessage))errorBlock;

/**
 *  好友添加请求 -> 忽略
 *  @param userId       添加请求好友的id
 */
- (void)friendIgnoreWithUserId:(NSString *)userId onSuccess:(void (^)(void))successBlock onError:(void (^)(int errorCode, NSString *errorMessage))errorBlock;

/**
 *  好友删除
 *  @param userId       要删除好友的id
 */
- (void)friendDeleteWithUserId:(NSString *)userId onSuccess:(void (^)(void))successBlock onError:(void (^)(int errorCode, NSString *errorMessage))errorBlock;

/**
 *  好友添加别名(备注名称)
 *  @param userId       好友的id
 *  @param alias       别名
 */
- (void)friendRemarkWithUserId:(NSString *)userId andAlias:(NSString *)alias onSuccess:(void (^)(void))successBlock onError:(void (^)(int errorCode, NSString *errorMessage))errorBlock;


@end
  • 以上方法都在 demo 中展示了其用法,可供参考 ^_^

安装方法

To run the example project, clone the repo, and run pod install from the Example directory first.

pod 文件

ONOChat is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ONOChat'

作者

Kevin, [email protected]

License

ONOChat is available under the MIT license. See the LICENSE file for more info.

onochat-iossdk's People

Contributors

carrotlsp avatar lhs168 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.