# 2.1 集成前准备工作

注册开发者账号

登录凡泰极客官网 (opens new window),点击右上角登录 (opens new window),选择注册,填入注册信息。

为了更好的服务开发者,我们会给每个开发者指定一个仓库,用于后续的SDK交付工作,该类型的仓库是私有仓库,对于不是该指定团队的开发者,是没有权限查看的,要想获取私有仓库的开发者权限,请联系我们 (opens new window)

申请AppKey

金易联 SDK在初始化时,需要配置appKey,该appKey是与bundleId以及客户的后台服务器关联的,所以需要客户提供bundleId和服务器地址,然后再生成appKey。

金易联 SDK说明

FinChat.framework : SDK核心组件 MatrixSDK.framework : SDK核心组件 fincore.framework : SDK核心组件 FinChatSDK.framework : 核心SDK,提供定制化接口以及SDK的初始化类 Realm.framework : 数据存储服务 FinApplet.framework : 小程序组件 FINWebRTC.framework : 音视频会议核心组件 JitsiMeet.framework : 音视频核心框架

注意:目前的Swan SDK默认是不包含模拟器的架构,所以运行Demo时,请使用真机进行调试。切记!切记!切记!

# 2.2 集成金易联 SDK

为了更好的服务开发者,以及后续的SDK交付工作,所以金易联 SDK 使用了Cocoapods的方式集成。

首先,在项目的根目录下创建Podfile文件,然后添加source 和 金易联SDK的依赖。

使用Podfile文件示例:

platform :ios, "9.0"
source 'https://git.finogeeks.com/cocoapods/finogeeks'
source 'https://git.finogeeks.com/cocoapods/FinPods'
source 'https://github.com/CocoaPods/Specs.git'

inhibit_all_warnings!

target "FINSwanCocopods" do
    pod 'FinChat-Mixins'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
            config.build_settings['ENABLE_STRICT_OBJC_MSGSEND'] = 'NO'
            config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
    end
  end
end

前面说到如果是开发者的指定私有仓库,需要将source 修改为实际的地址。

比如 source 'https://git.finogeeks.com/cocoapods/finogeeks' 修改为 source 'https://git.finogeeks.com/cocoapods/[私有仓库名称]()'

如果是指定的版本号,请加上版本号,例如:

pod 'FinChat-Mixins','3.9.602'

# 2.3 安装金易联 SDK

在 Mac 电脑 终端里,进入到podfile 所在的目录,然后执行如下命令:

pod install

当然,你也可以使用 pod update

注意:安装完成后,使用xxxx.xcworkspace重新打开工程。

# 2.4 修改工程配置

  1. Xcode 10以上的版本,需要修改File->Workspace Settings->Build System为:【Legacy Build System】。

  1. 在Project->Build Settings->Bitcode 设置为【NO】。

至此,金易联SDK的集成已经完成,下面介绍SDK的使用。

# 2.5 金易联SDK的使用

5.1 SDK的初始化

首先,导入头文件。

#import <FinChatSDK/FinChatSDK.h>

然后,构造SDK配置参数

// 1.设置信息app的运行环境和信息
NSDictionary *appConfig = @{
           @"finochatApiURL":@"https://mini.finogeeks.club",//app的 服务器地址
           @"finochatApiPrefix":@"/api/v1",        //app 服务器的版本号
           @"appType":@"STAFF",                    //app 的类型 目前有 STAFF(员工端) 和 RETAIL(客户端)两种
           @"appId":[NSBundle mainBundle].bundleIdentifier,//项目的唯一标示
           @"appKey":@"请填写您申请的appKey" ,               //App 授权码
           @"pushGatewayURL":@"http://push-service.platform:5000/_matrix/push/v1/notify", //app APNS推送服务地址
           @"pusherAppIdProd":[NSBundle mainBundle].bundleIdentifier, //app  APNS生产环境的推送appId 即BundleId
           @"pusherAppIdDev":[NSBundle mainBundle].bundleIdentifier, //app APNS开发环境的推送appId 即BundleId
           @"settings":@{                         //功能的配置信息
                         @"urlSchemaPrefix":@"urlSchema", //app的 urlSchema(用于app的分享和)
                        },
            };

// 2.构造配置信息对象
FinoChatConfig *config = [[FinoChatConfig alloc] initWithDict:appConfig];
FinoChatOptions *options = [FinoChatOptions optionsWithConfig:config];
options.isAPNSRegistered = YES;

NSError *error = nil;
// SDK的初始化
BOOL isInit = [[FinoChatClient sharedInstance] fino_initSDK:options error:&error];

5.2 SDK UI功能介绍

5.2.1 登录API

目前提供账号密码、手机号验证码以及token三种登录方式。

//1 账户密码登录
[[FinoChatClient sharedInstance].finoAccountManager login:@"staff1" password:@"123456" success:^(NSDictionary *result) {

} failure:^(NSError *error) {

}];

//2 token登录
[[FinoChatClient sharedInstance].finoAccountManager loginWithToken:@"token" success:^(NSDictionary *result) {

} failure:^(NSError *error) {

}];

//3 账号密码登录
[[FinoChatClient sharedInstance].finoAccountManager loginWithMobile:@"138xxxxxxxx" verification:@"1234" success:^(NSDictionary *result) {

} failure:^(NSError *error) {

}];

//退出当前账号
[[FinoChatClient sharedInstance].finoAccountManager logout];

5.2.2 获取会话列表

UIViewController *conversation = [[FinoChatClient sharedInstance].finoChatUIManager conversationViewControllerWithDelegate:nil];

5.2.3 根据房间ID打开聊天房间

NSString *roomId = @"xxxx";//聊天房间的id
UIViewController *chatRoomController = [[FinoChatClient sharedInstance].finoChatUIManager chatViewControllerWithRoomId:roomId];

5.2.4 获取金易联SDK工作界面

UIViewController *workController = [[FinoChatClient sharedInstance].finoSwanUIManager swanOrderListViewController];

5.2.5 获取金易联SDK个人信息界面

UIViewController *mimeController = [[FinoChatClient sharedInstance].finoSwanUIManager swanMineViewController];

5.2.6 根据员工id 获取员工信息

NSString *staffId = @"xxx";//员工id
UIViewController *mimeController = [[FinoChatClient sharedInstance].finoSwanUIManager swanStaffInfoWithStaffId:staffId completeBlock:^(NSError *error, NSDictionary *responseObj) {

}];

5.2.7 根据员工id 获取员工信息

NSString *staffId = @"xxx";//员工id
UIViewController *mimeController = [[FinoChatClient sharedInstance].finoSwanUIManager swanStaffInfoWithStaffId:staffId completeBlock:^(NSError *error, NSDictionary *responseObj) {

}];

5.2.8 获取营销线索

 [[FinoChatClient sharedInstance].finoSwanUIManager swanMarketingCluesListWithParameter:nil completeBlock:^(NSError *error, NSDictionary *responseObj) {

   }];

5.2.9 获取转发助手文章列表

   NSMutableDictionary *parameter = @{@"page":@(0),@"size":@(20)};
    [[FinoChatClient sharedInstance].finoSwanUIManager swanForwardingAssistantWithParameter:parameter completeBlock:^(NSError *error, NSDictionary *responseObj) {

    }];

5.2.10 修改抢单和派单通知

    NSMutableDictionary *parameter = @{@"rush":@(YES),@"dispatch":@(YES)};
    [[FinoChatClient sharedInstance].finoSwanUIManager swanEditeOrderNoticeStatusWithParameter:parameter completeBlock:^(NSError *error, NSDictionary *responseObj) {

    }];


5.2.11 获取抢单和派单通知状态

   [[FinoChatClient sharedInstance].finoSwanUIManager swanOrderNoticeStatusWithParameter:nil completeBlock:^(NSError *error, NSDictionary *responseObj) {

    }];

注:更多的接口和API请访问 FinoChatSDK 文档 (opens new window)。 有些接口会校验appKey的有效性和用户是否登录,否则会返回nil。