【问题标题】:Using ChatSDK with Zendesk iOS Swift将 ChatSDK 与 Zendesk iOS Swift 一起使用
【发布时间】:2020-05-10 09:00:12
【问题描述】:

我正在将 ZDCChat 更新为 ChatSDK。我现在面临一个问题。

每次我来到聊天屏幕Chat.accountProvider?.observeAccount,这个观察者都会告诉我No Agent Available。但是代理可以在我的浏览器上使用。

第二件事是当我输入消息并点击发送时,它没有显示在我的聊天屏幕上。

这里是代码。这是在 AppDelegate 中:

 let chatConfiguration = ChatConfiguration()
    chatConfiguration.isPreChatFormEnabled = false

    let chatAPIConfiguration = ChatAPIConfiguration()
    chatAPIConfiguration.department = "Blah"
    chatAPIConfiguration.visitorInfo = VisitorInfo(name: "BlahUser", email: "test@test.com", phoneNumber: "")
    Chat.instance?.configuration = chatAPIConfiguration;

    Chat.initialize(accountKey: "------my key------", queue: .main)

这就是我开始聊天的方式

 let chatAPIConfiguration = ChatAPIConfiguration()
    chatAPIConfiguration.department = "iOS App"
    chatAPIConfiguration.visitorInfo = VisitorInfo(name: nameField.text!, email: emailField.text!, phoneNumber: "")
    Chat.instance?.configuration = chatAPIConfiguration;

do {
      let chatEngine = try ChatEngine.engine()
      let viewController = try Messaging.instance.buildUI(engines: [chatEngine], configs: [])
        viewController.view.backgroundColor = Constants.bgColor
      self.navigationController?.pushViewController(viewController, animated: true)
    } catch {

      // handle error
        print("error initaiting chat")
    }

结束聊天也不起作用,我一直在启动会话。

 let stateToken = Chat.chatProvider?.observeChatState { (state) in
        // Handle logs, agent events, queue position changes and other events
        print("My Session status: ", state.chatSessionStatus)
        switch state.chatSessionStatus {
        case .configuring:
            print("COnfiguring")
        case .ended:
            print("Ended")
        case .ending:
            print("Ending")
        case .initializing:
            print("initializing")
        case .started:
            print("started")
        default:
            print("Default Case")
        }
    }

【问题讨论】:

    标签: ios swift zendesk zendesk-api chatsdk


    【解决方案1】:

    我也有同样的问题

    尝试评论这一行:

    let chatAPIConfiguration = ChatAPIConfiguration()
        chatAPIConfiguration.department = "iOS App"
        chatAPIConfiguration.visitorInfo = VisitorInfo(name: nameField.text!, email: emailField.text!, phoneNumber: "")
        Chat.instance?.configuration = chatAPIConfiguration;
    

    chatConfiguration.preChatFormConfiguration = formConfiguration
    

     let chatConfiguration = ChatConfiguration()
        chatConfiguration.isPreChatFormEnabled = false
    
        let chatAPIConfiguration = ChatAPIConfiguration()
        chatAPIConfiguration.department = "Blah"
        chatAPIConfiguration.visitorInfo = VisitorInfo(name: "BlahUser", email: "test@test.com", phoneNumber: "")
        Chat.instance?.configuration = chatAPIConfiguration;
    

    更新:

    我有同样的问题,我写了支持。 他们回复了我很长时间,通信已经进行了将近一个星期。

    我决定更详细地分析,因为这样的错误可能是什么。

    我尝试在聊天中发送图片 - 聊天获得。

    但如果你只是写短信,它们是不会发送的。

    然后我决定评论有关用户的信息,然后一切正常,但是在聊天信息中看不到用户写的内容...

    【讨论】:

    • 感谢您对社区的贡献。这可能是一个正确的答案,但对您的代码提供额外的解释会很有用,以便开发人员能够理解您的推理。这对于可能不熟悉语法的新开发人员特别有用。此外,它可以帮助减少对后续问题的需求。您介意用更多详细信息更新您的评论吗?
    • 你能详细解释一下我在这里做错了什么吗?如果我对您告诉我的上述内容发表评论,那么聊天将如何启动?
    • 还有一件事是我没有得到任何观察者的结束聊天。我已经更新了我的问题
    • Chat 现在可以发送和接收消息了。非常感谢。
    • @Linyx 你知道当座席离开聊天室时如何获得回调吗? ?
    【解决方案2】:

    如果你们中的任何人发现此问题并遇到问题,请联系我,我们将一起解决问题。

    所以,经过这么多的斗争。

    发现我们不需要这些代码行:

    let chatAPIConfiguration = ChatAPIConfiguration()
    chatAPIConfiguration.department = "iOS App"
    chatAPIConfiguration.visitorInfo = VisitorInfo(name: nameField.text!, email: emailField.text!, phoneNumber: "")
    Chat.instance?.configuration = chatAPIConfiguration;
    
    chatConfiguration.preChatFormConfiguration = formConfiguration
    

    删除此代码后,该应用程序运行正常。 我仍在努力寻找如何自定义 UI。

    特别感谢@Linyx。感谢您帮助我找到解决方案。

    【讨论】:

      【解决方案3】:

      Saad Ullah,我在网站上的聊天设置中启用了部门,现在可以使用 ios 聊天...你也可以检查一下吗?

      还原代码中的更改并尝试

      【讨论】:

      • 酷让我也试试。但是我面临另一个问题,当代理离开聊天时没有收到回电。你知道怎么获得吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-10
      • 2014-01-04
      • 2017-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多