Setting up the Chat SDK
This document describes how to add the Chat SDK to your project and initialize it in your application. After completing this setup, see Starting and configuring a chat.
Adding the Chat SDK to a project
You can add the Chat SDK to your project with CocoaPods or manually in Xcode.
Adding the SDK with CocoaPods
CocoaPods is a dependency manager that lets you add third-party frameworks and libraries to projects. For installation instructions, see Install CocoaPods.
If not already done, create a Podfile for your project as follows:
In Terminal, navigate to the top-level folder of your project (the one with the xcodeproj file).
Create a Podfile with the following command:
$ pod init
Open the file in Xcode with the following command:
$ open -a Xcode Podfile
The content should look as follows:
# Uncomment this line to define a global platform for your project # platform: ios, '9.0' target 'My Sample App' do use_frameworks! end
If you're using Objective-C, comment out
Add the Chat SDK to your Podfile and install the SDK in your project as follows:
pod 'ZDCChat'to the
target 'My Sample App' do ... pod 'ZDCChat' end
To install only the ChatAPI and build the UIs yourself:
Save the Podfile.
Run the following command in Terminal:
$ pod install
Note: If you installed a previous version of the SDK with CocoaPods, run
pod update ZDCChatfirst to update the SDK pod on your system.
Because your project now contains a dependency managed by CocoaPods, you must open the project in Xcode by double-clicking the .xcworkspace file, not .xcodeproj .
For more information, see Using CocoaPods on cocoapods.org.
Adding the SDK manually
Download the ZIP file from the Chat SDK repo on Github, and unzip the file on your hard drive.
In XCode, select your project in Project navigator:
Select File > Add Files to "your_project_name" from the Xcode menu.
Navigate to the unzipped SDK folder and multi-select the following items:
To install only the ZDCChatAPI and build the UIs yourself, you only need ZDCChatAPI.framework.
Make sure the rest of the Add Files settings are set as follows:
- Destination - select Copy items if needed
- Added folders - select Create groups
- Add to targets - make sure your application and all relevant targets are selected
Initializing the Chat SDK
The Chat SDK should be initialized in the following method in the application delegate:
The method runs just before the application moves to the active state.
The initialization code requires a Zendesk Chat account key. You'll need access to the Zendesk Chat dashboard to get the key. If you don't have access, ask somebody who does to perform the first 2 steps.
In the Zendesk Chat dashboard, click your avatar in the upper-right corner, then select Check Connection.
Copy and save the account key. It should be the second item in the list.
In your project in Xcode, add the following import statement at the top of the AppDelegate file:
Add the the following initialization code to the delegate method:
Replace the "your_account_key" placeholder with the account key from the Zendesk Chat dashboard.
For additional settings you can set on initialization, see ZDCConfig.