iBotSDK
示例
要运行示例项目,请克隆存储库,然后首先从 Example 目录运行 pod install
需求
- iOS 11.0+
- Xcode 11 (Swift 4.0)
安装
iBotSDK 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'iBotSDK'
or
pod 'iBotSDK', '~> 1.9.6'
用法
API 密钥
您可以在这里获取API密钥。
基础
import iBotSDK
IBotSDK.shared.showIBotButton(in: self.view, apiKey:'YOUR_API_KEY')
#import <iBotSDK.h>
[[IBotSDK shared] showIBotButtonIn:[self view] apiKey:@"YOUR_API_KEY"];
编辑 IBotChatButton
let button = IBotSDK.shared.showIBotButton(in: self.view, apiKey:'YOUR_API_KEY')
// change position
button.frame.origin.y = button2.frame.origin.y - 100
// open in navigation viewcontroller
button.openInModal = false
// dragging
button.canDrag = true
// change button default background color
button.buttonBackgroundColor = .white
// open directly
IBotSDK.shared.showChatbot(parent: self, apiKey: 'YOUR_API_KEY', openInModal: false)
IBotChatButton *button = [[IBotSDK shared] showIBotButtonIn:[self view] apiKey:@"YOUR_API_KEY"];
// change position
button.center = CGPointMake(button.center.x, button.center.y - 50);
// open in navigation viewcontroller
button.openInModal = false;
// dragging
button.canDrag = true;
// change button default background color
button.buttonBackgroundColor = UIColor.whiteColor;
使用回调
当需要从聊天框接收消息并直接执行指定操作时,可以定义并使用。
IBotSDK.shared.showIBotButton(in: self.view, apiKey: @"YOUR_API_KEY") { (ibotVC, command) in
if let _ = ibotVC.navigationController {
self.showCommandAlert(command)
}
else {
ibotVC.dismiss(animated: true) {
self.showCommandAlert(command)
}
}
}
禁用动画
当要在消息显示部分去除聊天机器人按钮的动画播放时,在调用showIBotButton()时将playAnimation值设置为false即可。
IBotSDK.shared.showIBotButton(in: self.view, apiKey: @"YOUR_API_KEY", playAnimation: false)
作者
Enliple, [email protected]
许可
iBotSDK 采用MIT许可。更多信息请查看LICENSE文件。