Recent searches


No recent searches

iOS SDK initWithName Broken as of 2 days ago



Posted Nov 30, 2021

As of 2 days ago trying to set initWithName on ZDKVisitorInfo causes the chat not to work. The same issue is present if ZDKChatFormConfiguration is set with initWithName ZDKFormFieldHidden. Chat works fine with name set to NULL and the field required or optional in the form, but if the name is given, it does not connect to the chat. Also if the name is not given and the field in the form set to ZDKFormFieldHidden it also no longer connects. This started 2 days ago in prod apps and I suspect it's an issue in either the SDK or server. I cannot find actual support so posting here.


0

4

4 comments

image avatar

Greg Katechis

Zendesk Developer Advocacy

Hi Neil Hannah, sorry to hear about the headaches you're running into! I've seen some internal tickets that were created for your team regarding this issue and I've been trying to find some logs that would help me see what's going on here. I haven't actually found anything for the last week, so I think that we need to drill in a bit more on this.

Could you share the code snippet where you are setting your visitor info, as well as any other potentially relevant snippets that could be related to this? In the interim, take a look at this article to see if that helps at all!

0


Hi Greg, I will try to sum it up here.

Working:

`config.visitorInfo = [[ZDKVisitorInfo alloc] initWithName:nil email:@"neil@test.com"phoneNumber:@"1234567890"];`

`[[ZDKChatFormConfiguration alloc] initWithName:ZDKFormFieldStatusOptional email:ZDKFormFieldStatusHidden phoneNumber:ZDKFormFieldStatusHidden department:ZDKFormFieldStatusHidden]`
Not working:
`config.visitorInfo = [[ZDKVisitorInfo alloc] initWithName:nil email:@"neil@test.com"phoneNumber:@"1234567890"];`
 
`[[ZDKChatFormConfiguration alloc] initWithName:ZDKFormFieldStatusHidden email:ZDKFormFieldStatusHidden phoneNumber:ZDKFormFieldStatusHidden department:ZDKFormFieldStatusHidden]`
 
Not working:
`config.visitorInfo = [[ZDKVisitorInfo alloc] initWithName:@"neil" email:@"neil@test.com"phoneNumber:@"1234567890"];`
 
`[[ZDKChatFormConfiguration alloc] initWithName:ZDKFormFieldStatusOptional email:ZDKFormFieldStatusHidden phoneNumber:ZDKFormFieldStatusHidden department:ZDKFormFieldStatusHidden]`
 
So basically if I provide the name, regardless of the form setting, I can no longer connect. If I don't provide the name, if the form setting has name optional or required, I can connect. But if I don't provide the name, and the form is set to hidden for name, I still cannot connect.

0


image avatar

Greg Katechis

Zendesk Developer Advocacy

Hi again Neil! My apologies, I should have been more specific about what I needed. I was hoping to have the entire block of code where you are both creating the underlying function, as well as the code where you are using this. 

It would also be good if we could rule out an issue with our SDK by having you try this with our sample apps. You would want to use the ChatSDKSamples, as opposed to the v1. Let me know how this goes, as I'm not seeing this same issue on my end.

0


Hi,

As I initially found a workaround it took me a bit to get back to this, but using the example, which is in swift instead of ObjC, I find the exact same issue. I actually found another issue as well where setting department also caused message sending issues. So to reiterate, if the name is set to hidden, and not given, FAIL, if name required, and given, FAIL, if department given FAIL. Here is the sample code in a failed state... comment out the `.department` and swap the commented `visitorInfoTest` for the uncommented one and you will find another failure. You can paste this into your ZendeskMessaging file in the sample project, it has very few changes from that.

 

//

//  ZendeskMessaging.swift

//  UnifiedSDK

//

//  Created by Zendesk on 17/04/2020.

//  Copyright © 2020 Zendesk. All rights reserved.

//

 

import Foundation

import MessagingSDK

import MessagingAPI

import CommonUISDK

import ChatSDK

import ChatProvidersSDK

 

final class ZendeskMessaging: NSObject, JWTAuthenticator {

 

    static let instance = ZendeskMessaging()

 

    static var themeColor: UIColor? {

        didSet {

            guard let themeColor = themeColor else { return }

            CommonTheme.currentTheme.primaryColor = themeColor

        }

    }

 

    #warning("Please provide Chat account key")

    let accountKey = ""

 

    var authToken: String = "" {

        didSet {

            guard !authToken.isEmpty else {

                resetVisitorIdentity()

                return

            }

            Chat.instance?.setIdentity(authenticator: self)

        }

    }

 

    // MARK: Configurations

    var messagingConfiguration: MessagingConfiguration {

        let messagingConfiguration = MessagingConfiguration()

        messagingConfiguration.name = "Chat Bot"

        return messagingConfiguration

    }

 

    var chatConfiguration: ChatConfiguration {

        let chatConfiguration = ChatConfiguration()

        chatConfiguration.isAgentAvailabilityEnabled = true

        chatConfiguration.isPreChatFormEnabled = true

        chatConfiguration.preChatFormConfiguration.name = FormFieldStatus.required

        chatConfiguration.preChatFormConfiguration.email = FormFieldStatus.required

        chatConfiguration.preChatFormConfiguration.phoneNumber = FormFieldStatus.required

        chatConfiguration.preChatFormConfiguration.department = FormFieldStatus.hidden

        return chatConfiguration

    }

 

    var chatAPIConfig: ChatAPIConfiguration {

        let chatAPIConfig = ChatAPIConfiguration()

        chatAPIConfig.tags = ["iOS", "chat_v2"]

        chatAPIConfig.department = "Neil test" // This line commented out will work

        let visitorInfoTest = VisitorInfo(email: "neil@gmail.com", phoneNumber: "1111111111")

//        let visitorInfoTest = VisitorInfo(name: "Neil Test", email: "neil@gmail.com", phoneNumber: "8607489943") // This line replacing one above it causes app not to work

        chatAPIConfig.visitorInfo = visitorInfoTest

        return chatAPIConfig

    }

 

    // MARK: Chat

    func initialize() {

        setChatLogging(isEnabled: true, logLevel: .verbose)

        Chat.initialize(accountKey: accountKey, appId: "")

    }

 

    func setChatLogging(isEnabled: Bool, logLevel: LogLevel) {

        Logger.isEnabled = isEnabled

        Logger.defaultLevel = logLevel

    }

 

    func resetVisitorIdentity() {

        Chat.instance?.resetIdentity(nil)

    }

 

    func getToken(_ completion: @escaping (String?, Error?) -> Void) {

        completion(authToken, nil)

    }

 

    // MARK: View Controller

    func buildMessagingViewController() throws -> UIViewController {

        Chat.instance?.configuration = chatAPIConfig

        return try Messaging.instance.buildUI(engines: engines,

                                              configs: [messagingConfiguration, chatConfiguration])

    }

}

 

extension ZendeskMessaging {

    // MARK: Engines

    var engines: [Engine] {

        let engineTypes: [Engine.Type] = [ChatEngine.self]

        return engines(from: engineTypes)

    }

 

    func engines(from engineTypes: [Engine.Type]) -> [Engine] {

        engineTypes.compactMap { type -> Engine? in

            switch type {

            case is ChatEngine.Type:

                return try? ChatEngine.engine()

            default:

                fatalError("Unhandled engine of type: \(type)")

            }

        }

    }

}

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post