Latest0.1.5
Homepagehttps://github.com/rxdxxxx/WBChatIMKit
LicenseMIT
Platformsios 8.0, requires ARC
DependenciesFMDB, AVOSCloud, AVOSCloudIM
Authors

Example

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

Requirements

  • iOS 8.0 or later
  • Xcode 7.3 or later

简介

安装

Podfile文件中添加下面👇这行代码

pod 'WBChatIMKit'

初始化

首先需要在 LeanCloud 注册自己的应用,得到对应的 AppIdclientKey 后在程序中设置对应信息

#import <WBChatIMKit/WBChatIMKit.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    [WBChatKit setAppId:@"AppId"
              clientKey:@"clientKey"];
    return YES;
}

连接服务器

SDK初始化成功后, 就可以用某一身份连接服务器. 实例代码如下.

[[WBChatKit sharedInstance] openWithClientId:@"10000"
                                     success:^(NSString * _Nonnull clientId)
 {
     NSLog(@"链接成功");

 } error:^(NSError * _Nonnull error) {
     NSLog(@"链接失败: %@",
           error.description);
 }];

展示会话列表

本项目提供了会话列表页面. 可以直接使用 WBChatListController 也可以继承这个类实现自己的逻辑.


WBChatListController *vc = [[WBChatListController alloc]init];

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];

[self presentViewController:nav animated:YES completion:nil];

第一次登陆是没有会话信息的, 你可以给任意ID发送一条消息,就可以在会话列表中看到这条记录了.

发送一条消息:
WBMessageModel *text = [WBMessageModel createWithText:[NSDate new].description];

[[WBChatKit sharedInstance] sendTargetUserId:@"30000"
                                     message:text
                                     success:^(WBMessageModel * _Nonnull aMessage)
{
     NSLog(@"消息发送成功");

} error:^(WBMessageModel * _Nonnull aMessage, NSError * _Nonnull error) {

     NSLog(error.description);

}];
会话列表页面具体效果
正常效果删除会话
会话列表页面具体效果会话列表页面删除

会话页面

本项目提供了会话页面. 可以直接使用 WBChatViewController 也可以继承这个类实现自己的逻辑.

WBChatListController的方法中已经实现页面的跳转.

// WBChatListController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    WBChatListCellModel *cellModle = self.dataArray[indexPath.row];

    WBChatViewController *vc = [WBChatViewController createWithConversation:cellModle.dataModel.conversation];
    vc.title = cellModle.title;
    [self.navigationController pushViewController:vc animated:YES];
}
会话页面具体效果
会话正常效果emoji键盘更多
会话页面具体效果会话页面emoji键盘效果会话页面更多具体效果

断开连接

断开连接后,就不会再收到这个账号的消息了.

- (IBAction)logOut{
    [[WBChatKit sharedInstance] closeWithCallback:^(BOOL succeeded, NSError * _Nonnull error) {
        if (succeeded) {
            NSLog(@"退出成功");
        }else{
            NSLog(@"退出失败");
        }
    }];
}

其他

更多细节介绍请查看 这里

依赖库

  • ‘FMDB’
  • ‘AVOSCloud’
  • ‘AVOSCloudIM’

参考资源

Author

Ding RedRain, [email protected]

License

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

Latest podspec

{
    "name": "WBChatIMKit",
    "version": "0.1.5",
    "summary": "u57fau4e8eLeanCloudu7684IMu529fu80fd,u53efu4ee5u5febu901fu4f7fu7528u7684UIu6846u67b6",
    "description": "u63d0u4f9bu4e86u53d1u9001u6587u5b57,u56feu7247,u8bedu97f3u6d88u606fu7684u63a7u4ef6u63d0u4f9bu4e86u6700u8fd1u8054u7cfbu4ebau5217u8868u672au8bfbu6d88u606fu63d0u9192, u8349u7a3fu7f13u5b58u7b49u57fau7840u529fu80fd",
    "homepage": "https://github.com/rxdxxxx/WBChatIMKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "rxdxxxx": "[email protected]"
    },
    "source": {
        "git": "https://github.com/rxdxxxx/WBChatIMKit.git",
        "tag": "0.1.5"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": [
        "WBChatIMKit/Classes/**/*.{h,m}",
        "WBChatIMKit"
    ],
    "vendored_frameworks": "WBChatIMKit/Classes/VoiceLib/lame.framework",
    "resources": [
        "WBChatIMKit/Classes/Resource/*",
        "WBChatIMKit/**/*.xib"
    ],
    "requires_arc": true,
    "dependencies": {
        "FMDB": [],
        "AVOSCloud": [],
        "AVOSCloudIM": []
    }
}

Pin It on Pinterest

Share This