Mobile iOS SDK open ticket using ZDKRequestProvider()

2 Comentarios

  • Christopher Kennedy
    Zendesk Developer Advocacy
    Hi Jaume,
     
    Can you share the code where you're initializing the SDK (redact the initialization settings values) and setting the identity?
    0
  • Jaume Garcia Parcerisas

    Hi Christopher!

    This is the code I use to initialize the ZendeskSDK in the AppDelegate's 

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?)

    private func setupZendesk() {
            Zendesk.initialize(
                withChannelKey: EnvironmentManager.getValue(key: .zendeskChatChannelId),
                messagingFactory: DefaultMessagingFactory()) { result in
                    if case let .failure(error) = result {
                        print("[LOG] ZENDESK Messaging did not initialize.\nError: \(error.localizedDescription)")
                    } else {
                        print("[LOG] ZENDESK MESSAGING INITIALIZED!") <----- PRINTING THIS
                    }
                }

            ZendeskCoreSDK.Zendesk.initialize(
                appId: EnvironmentManager.getValue(key: .zendeskAppId),
                clientId: EnvironmentManager.getValue(key: .zendeskClientId),
                zendeskUrl: EnvironmentManager.getValue(key: .zendeskUrl)
            )

            Support.initialize(withZendesk: Zendesk.instance)
            AnswerBot.initialize(withZendesk: Zendesk.instance, support: Support.instance!)
            Chat.initialize(accountKey: EnvironmentManager.getValue(key: .zendeskAccountKey))

            let identity = Identity.createAnonymous()
            Zendesk.instance?.setIdentity(identity)
            print("[LOG] ZENDESK INITIALIZED! version: ", Zendesk.version())
        }

     

    And this is the function I use to set the user's identity:

    func zendeskIdentify() {
            var identity: Identity!

            if let accountKey = user?.zendeskJwtToken {
                Chat.initialize(accountKey: accountKey)
                identity = Identity.createJwt(token: accountKey)
            } else if let owner = userLegal {
                identity = Identity.createAnonymous(
                    name: "\(owner.firstName ?? "") \(owner.lastName ?? "")",
                    email: owner.email
                )
            } else {
                identity = Identity.createAnonymous(name: "Anonymous")
            }

            print("[LOG] Zendesk identity set!", identity as Any)
            Zendesk.instance?.setIdentity(identity)
        }

     

    The SDK's features I need to implement are:

    0

Iniciar sesión para dejar un comentario.

Tecnología de Zendesk