前瞻性 2.4.0

前瞻性 2.4.0

Matthew KnippenEvgeny OrekhovAndrew Schirmer Maintained.



前瞻性 2.4.0

Forethought - Solve iOS SDK

此仓库包含 Forethought iOS SDK 的框架和说明。

为了使用 Forethought Solve SDK,需要一个有效的 API 密钥。除了下面的文档外,还编写了 Objective-C & Swift 的示例应用程序,以及 SwiftUI 的实现。

安装

Swift 包管理器

  1. 在 Xcode 中,选择 文件 > 添加包

  2. 输入 Forethought iOS GitHub 仓库 URL(https://github.com/Forethought-Technologies/solve-ios

  3. 点击 添加包。按提示操作,Xcode 将自动下载框架。

Cocoapods

  1. Forethought 也可通过 CocoaPods 获取。

  2. Podfile 文件中添加以下行

    pod 'Forethought'
  3. 运行以下命令

    $ pod install
    
  4. 请确保从此以后使用 .xcworkspace 文件且 不要 使用 .xcodeproj

基本用法

  1. AppDelegate.swift 文件中,将 __YOUR_KEY_HERE__ 替换为有效的 Forethought API 密钥
    ForethoughtSDK.start(apiKey: "__YOUR_KEY_HERE__")
  2. 打开 Forethought 小部件
    import 'Forethought'
    
    ForethoughtSDK.show()

可选添加

工作流程上下文变量

传递通过 Forethought 控制面板定义的工作流程上下文变量

ForethoughtSDK.dataParameters = ["language":"EN", "user-email": "[email protected]", "workflow-context-variable": "value"]

移交方法

将客户从Forethought转移至Kustomer等代理聊天服务提供者

  1. 将委托设置为Forethought SDK。在展示界面之前完成此操作
    ForethoughtSDK.delegate = self
  2. 确保对象符合ForethoughtDelegate协议
    class ViewController: UIViewController, ForethoughtDelegate {
  3. 通过添加以下方法来符合ForethoughtDelegate
    func startChatRequested(handoffData: ForethoughtHandoffData) {}
  4. 在此添加移交实现。例如。
    Kustomer.show(...)
    Kustomer.startNewConversation(...)
  5. 移交完成后,sendHandoffResponse将根据是否成功将对话传递给代理聊天服务提供者来继续或更新Forethought对话。
    ForethoughtSDK.sendHandoffResponse(success: true)

移交示例

func startChatRequested(handoffData: ForethoughtHandoffData) {
    print("Chat Requested: \(handoffData)")

    // close forethought widget
    ForethoughtSDK.hide(animated: false)

    // start a Kustomer chat
    Kustomer.startNewConversation(initialMessage: KUSInitialMessage(body: handoffData.question, direction: .user))

    // if handoff was successful
    ForethoughtSDK.sendHandoffResponse(success: true)

    // if handoff was unsuccessful
    ForethoughtSDK.show()
    ForethoughtSDK.sendHandoffResponse(success: false)
}

直接使用导航控制器

直接在导航堆栈上附加Forethought SDK

@IBAction func contactSupportTapped() {
    ForethoughtSDK.show(fromNavigationController: self.navigationController)
}

插件

⛔️ 从2.0.0版本开始,插件已被弃用 ⛔️

文档

已提供文档为.doccarchive格式,以便直接在Xcode中查看完整文档。使用时,只需双击Forethought.doccarchive即可,Xcode将处理其余操作。