快速集成
本文档介绍 PDBotKit 的快速集成,只需三分钟即可在您的 APP 中增加智能客服功能。
(以下两种接入方式任选一种即可)
(一) 使用CocoaPods自动集成
在 Podfile 文件中加入:
pod 'PDBotKit'
之后执行 pod install 即可
(二) 手动集成
1. 下载 iOS SDK 文件并解压
2. 将 PDBotSDK 目录下的文件依次添加到工程中
- PDBotLib.framework
- PDBotKit.framework
- PDBotKit.bundle
- PDBotKit.strings
3. 添加依赖库
- AVFoundation.framework
- Foundation.framework
- MobileCoreServices.framework
- UIKit.framework
- libicucore.tbd
- libsqlite3.tbd
初始化SDK
// 包含头文件
#import <PDBotKit/PDBotKit.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 在APP启动时进行初始化
NSString* accessKey = @"[您的 Access Key]";
[[PDBotKitClient sharedClient] initWithAccessKey:accessKey];
// 在需要联系客服时加载会话界面
UIViewController* controller = [[PDUIChatController alloc] init];
UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
self.window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
}