---
schema_version: "1"
id: 9ae24880371703de1112c4c61bfc3dc213e94859f493a18a6c06d64865cc965e
title: Hidden Pre-Chat for iOS
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/service-cloud/messaging-in-app/guides/ios-pre-chat.md
canonical_url: https://developer.salesforce.com/docs/service/messaging-in-app/guide/ios-pre-chat.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1e3f63f7730c5519396255d39227522dfa969a8765e0ed197d40d255e4ae54de
products:
  - Enhanced In-App Chat
  - Service Cloud Developer Content
---
# Hidden Pre-Chat for iOS

Use hidden pre-chat fields to capture valuable information without asking the customer directly for it.


**important:** This feature requires version 1.2.0 or later of the Enhanced In-App Chat SDK.


This article applies to the following implementations:

| UI SDK | Core SDK |
| :----: | :------: |
|   ✅   |    ✅    |


After you [set up pre-chat in Salesforce](https://help.salesforce.com/s/articleView?id=service.miaw_custom_prechat_2.htm), the UI SDK automatically presents the pre-chat form to the user and passes this information to Salesforce. If you're not using the UI SDK, the [Core SDK documentation](https://developer.salesforce.com/docs/service/messaging-in-app/guide/ios-core-sdk.md) describes how to perform this process programmatically. To use hidden pre-chat fields, use the Core SDK. If you want to use this feature with the UI SDK, use the Core SDK with your UI SDK.

This article describes the steps that you must take from your app to send any user data _not_ visible in the pre-chat form. This data is also described as hidden pre-chat fields. To learn about and set up pre-chat, see [Customize Pre-Chat for Enhanced Chat](https://help.salesforce.com/s/articleView?id=service.miaw_custom_prechat_2.htm).

After you set up hidden pre-chat fields in Salesforce, you can populate these values using the SDK.


1. Implement the [`HiddenPreChatDelegate`](https://salesforce-async-messaging.github.io/messaging-in-app-ios/documentation/smiclientcore/hiddenprechatdelegate) interface. This delegate contains the `didRequestPrechatValues` method, which the SDK calls when it needs pre-chat values.
2. Add your delegate to the SDK using the `CoreClient.preChatDelegate` property. See the [`CoreClient`](https://salesforce-async-messaging.github.io/messaging-in-app-ios/documentation/smiclientcore/coreclient) reference documentation.

```
class HiddenPrechatDelegateImplementation: HiddenPreChatDelegate {

  func core(_ core: CoreClient!,
            conversation: Conversation!,
            didRequestPrechatValues hiddenPreChatFields: [HiddenPreChatField]!,
            completionHandler: HiddenPreChatValueCompletion!) {

    // Use the conversation object to inspect info about the conversation

    // Fill in all the hidden pre-chat fields
    for preChatField in hiddenPreChatFields {
      // preChatField.label contains the label
      // preChatField.identifier contains the conversation identifier
      // preChatField.value is where you populate the field with a value

      preChatField.value = "My hidden pre-chat value"
    }

    // Pass pre-chat fields back to SDK
    completionHandler(hiddenPreChatFields)
  }
}
```

**note:** 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](https://developer.salesforce.com/docs/service/messaging-in-app/guide/ios-ui-sdk.md) or [Build a Core SDK App](https://developer.salesforce.com/docs/service/messaging-in-app/guide/ios-core-sdk.md) for more information.

```
// Create an instance of the hidden pre-chat delegate
let myPreChatDelegate = HiddenPrechatDelegateImplementation()

// Create a core client from a config
let coreClient = CoreFactory.create(withConfig: config)

// Assign the hidden pre-chat delegate
coreClient.preChatDelegate = myPreChatDelegate
```

After you register your delegate, the SDK automatically calls your `didRequestPrechatValues` method before a conversation begins.
