# cimkit **Repository Path**: Siter/cimkit ## Basic Information - **Project Name**: cimkit - **Description**: CimKit是基于CIM项目框架下的iOS端SDK。配合CIM服务我们可以快速搭建属于自己的推送系统、IM系统。 - **Primary Language**: Objective-C - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 11 - **Forks**: 3 - **Created**: 2020-11-23 - **Last Updated**: 2024-04-03 ## Categories & Tags **Categories**: ios-modules **Tags**: None ## README # cimkit #### 介绍 CimKit是基于[CIM项目](https://gitee.com/farsunset/cim)框架下的iOS端SDK。配合CIM服务我们可以快速搭建属于自己的推送系统、IM系统。 Requirements ---------------- 项目要求 : + ```iOS10``` + ```ARC``` Podfile ---------------- ``` use_frameworks! pod 'CimKit' ``` 然后运行一下命令安装: ``` $ pod install ``` 使用方法 ---------------- ##### 1. 导入头文件 ``` #import "CIMHeader.h" ``` ##### 2. 初始化配置 ``` [[CIMService instance] configHost:@"192.168.51.197" onPort:23456]; ``` ##### 3. 绑定用户 ``` [[CIMService instance] connectionBindUserId:@"111111"]; ``` ##### 4. 添加监听回调 ``` [[CIMService instance] addMessageObserver:self]; [[CIMService instance] addConnectionObserver:self]; ``` ##### 5. 移除回调 ``` [[CIMService instance] removeMessageObserver:self]; [[CIMService instance] removeConnectionObserver:self]; ``` ##### 6. CIMPeerMessageObserver回调说明 ``` /// 接受到消息 /// @param msg msg description -(void)cimHandleMessage:(CIMMessageModel * _Nonnull)msg; /// 消息解析失败 /// @param data data description -(void)cimHandleMessageError:(NSData * _Nonnull)data; ``` ##### 7. CIMConnectionObserver回调说明 ``` /// 用户绑定成功 /// @param bindSuccess bindSuccess description -(void)cimDidBindUserSuccess:(BOOL)bindSuccess; /// 连接成功 -(void)cimDidConnectSuccess; /// 断开连接 -(void)cimDidConnectClose; /// 连接失败 /// @param error res description -(void)cimDidConnectError:(NSError *_Nullable)error; ``` ##### 8. 其他方法说明 ``` +(CIMService*)instance; /// 配置IM服务器 /// @param host host description /// @param port port description -(void)configHost:(NSString *)host onPort:(NSInteger)port; /// 连接服务器并绑定用户 /// @param userId userId description -(void)connectionBindUserId:(NSString *)userId; /// 添加消息监听回调 /// @param observer observer description (可添加多个)不同时记得Remove -(void)addMessageObserver:(id)observer; /// 添加连接状态监听回调 /// @param observer observer description (可添加多个)不同时记得Remove -(void)addConnectionObserver:(id)observer; /// 移除监听 /// @param observer observer description -(void)removeMessageObserver:(id)observer; /// 移除监听回调 /// @param observer observer description -(void)removeConnectionObserver:(id)observer; /// 退出后台 断开连接 -(void)enterBackground; /// 进入前台重新连接 -(void)enterForeground; /// 重新连接 -(void)reconnect; /// 断开连接 -(void)disconnect; ``` 帮助和建议 ---------------- 如果你有好的建议和帮助您可以直接联系我:siterwu@gmail.com Todo ---------------- 1、数据缓存 2、通用UI组件 3、推送集成