User Verification for iOS

Pass user verification information to Salesforce to ensure that your customers get the best experience with a rep.

This feature requires version 1.2.0 or later of the Enhanced In-App Chat SDK.

Important

This article applies to the following implementations:

UI SDKCore SDK

Before you can use the SDK for user verification, you must upload the appropriate keys to Salesforce. To learn about and set up User Verification, see User Verification in Salesforce Help.

Avoid using the same ConversationID when switching deployments, as conversations from one deployment might not be accessible in the other, especially when changing between unverified and verified users.

Tip

Currently, this feature supports JWT tokens. Also, we don’t support chatting with verified users alongside unverified users. Your implementation must be designed for either verified users or unverified users.

Note

  1. When creating the UIConfiguration or Configuration object, add the optional userVerificationRequired argument and set it to true. See the CoreConfiguration reference documentation.
  2. Implement the UserVerificationDelegate interface. This delegate contains the userVerificationChallengeWithReason method, which the SDK calls when it requires user verification information.
  3. Add your delegate to the SDK using the CoreClient.userVerificationDelegate property. See the CoreClient reference documentation.
  4. Revoke the token when the user logs out by calling CoreClient.revokeTokenAndDeregisterDevice. See the CoreClient reference documentation.
Implement user verification delegate
1class UserVerificationDelegateImplementation: UserVerificationDelegate {
2
3
4  func core(_ core: CoreClient,
5              userVerificationChallengeWith reason: ChallengeReason,
6              completionHandler completion: @escaping UserVerificationChallengeCompletion) {
7    // Create a user verification object using the JWT
8    let customerIdentityToken = "{ JWT token goes here }"
9    let userVerification = UserVerification(customerIdentityToken: customerIdentityToken,
10                                            type: SMIAuthorizationType.SMIAuthorizationTypeJWT)
11
12    // Pass the object to the SDK
13    completion(userVerification, nil)
14  }
15
16}

This sample code requires the configuration object that you created when setting up the UI SDK or the Core SDK. See Build a UI SDK App or Build a Core SDK App for more information.

Note

Add your delegate to the core client object
1// Create an instance of the user verification delegate
2let myUserVerificationDelegate = UserVerificationDelegateImplementation()
3
4// Set the user verification flag on the config object to true…
5// If you're using the UI SDK:
6let config = UIConfiguration(url: configURL, userVerificationRequired: true, conversationId: conversationID)
7// Or, if you're using the Core SDK:
8// let config = Configuration(url: configURL, userVerificationRequired: true)
9
10
11// Create a core client from a config
12let coreClient = CoreFactory.create(withConfig: config)
13
14// Assign the user verification delegate
15coreClient.userVerificationDelegate = myUserVerificationDelegate

After you register your delegate, the SDK automatically calls the userVerificationChallegeWithReason method when it needs a valid token.