This getting started guide shows you how to integrate Zendesk Messaging into your iOS app.

Prerequisites

  • Zendesk Support or Suite plan
  • iOS 14 or later

1. Add the SDK Dependency

You can add the iOS SDK to your project using one of the following methods:

See Release Notes for the latest available versions.

Swift Package Manager

Swift Package Manager is a dependency manager for managing and distributing Swift code. It's integrated with the Swift build system. As of Xcode 11, you can use it inside Xcode.

  1. In Xcode, select File > Swift Packages > Add Package Dependency.

  2. Add the repository https://github.com/zendesk/sdk_messaging_ios/ and follow Xcode's instructions to add ZendeskMessagingSDK as a dependency. Swift Package Manager will resolve any required dependencies and download them as needed.

CocoaPods

CocoaPods is a dependency manager that lets you add third-party frameworks and libraries to projects. For installation instructions, see Install CocoaPods.

  1. In your Podfile, add the following:

    pod 'ZendeskSDKMessaging'
  2. Run the pod install command.

Carthage

Carthage is a dependency manager for iOS apps. For installation and usage instructions, see Installing Carthage in the Carthage readme on Github.

  1. Add the following dependency to your Cartfile.

    github "zendesk/sdk_messaging_ios"
  2. Run carthage update --use-xcframeworks.

    Carthage will check out and download all necessary dependencies to the Carthage/Checkouts directory in your project and place the binaries at Carthage/Build.

  3. Your targets FRAMEWORK_SEARCH_PATHS should be updated to point to Carthage/Build.

  4. On your targets General tab, drag each of the downloaded frameworks to the Frameworks, Libraries and Embedded Content section and embed the frameworks by selecting the Embed & Sign option.

Manual

  1. Download the following repositories:

    Each repository contains a .xcframework file that you import into your project.

  2. In Xcode, select your project in Project navigator:

  3. In Finder, navigate to where you extracted each of the SDKs.

  4. Ensure a Frameworks directory exists in the top level of your project directory. Create this directory if it doesn't exist.

  5. Copy the following items into the Frameworks folder in your project:

    • ZendeskSDKMessaging.xcframework
    • ZendeskSDK.xcframework
    • ZendeskSDKConversationKit.xcframework
    • ZendeskSDKUIComponents.xcframework
    • ZendeskSDKCoreUtilities.xcframework
    • ZendeskSDKFayeClient.xcframework
    • ZendeskSDKStorage.xcframework
    • ZendeskSDKHTTPClient.xcframework
    • ZendeskSDKLogger.xcframework
    • ZendeskSDKSocketClient.xcframework
    • ZendeskSDKGuideKit.xcframework
  6. Drag the frameworks into the Frameworks, Libraries and Embedded Content section of your project and embed the frameworks by selecting Embed & Sign option.

  7. In Build Settings, set the CLANG_ENABLE_MODULES field to YES.

2. Get your channel key

See How to get a channel key from Zendesk help.

3. Initialize the SDK

Add the following imports to your project:

Swift

import ZendeskSDKMessagingimport ZendeskSDK

Objective-C

#import <ZendeskSDKMessaging/ZendeskSDKMessaging.h>#import <ZendeskSDK/ZendeskSDK.h>

Initialize the SDK in your application class or at app launch:

Swift

Zendesk.initialize(withChannelKey: "<channel_key>",                   messagingFactory: DefaultMessagingFactory()) { result in    if case let .failure(error) = result {        print("Messaging did not initialize. Error: \(error.localizedDescription)")    }}

Objective-C

[Zendesk initializeWithChannelKey:@"<channel_key>"                 messagingFactory:[[ZDKDefaultMessagingFactory alloc] init]                completionHandler:^(Zendesk * _Nullable zendesk, NSError * _Nullable error) {    if (error != nil) {        NSLog(@"Zendesk did not initialize. Error: %@", error.localizedDescription);    }}];

4. Show Messaging

You can present the conversation screen anywhere in your app as needed:

Swift

if let viewController = Zendesk.instance?.messaging?.messagingViewController() {    self.navigationController?.show(viewController, sender: self)}

Objective-C

UIViewController *viewController = [Zendesk.instance.messaging messagingViewController];if (viewController != NULL) {    [self.navigationController showViewController:viewController sender:self];}

Presenting the conversation modally

You can also present the messaging view controller modally, which is useful if you want to display the conversation as a modal screen instead of pushing it onto a navigation stack.

Swift

if let viewController = Zendesk.instance?.messaging?.messagingViewController() {    let navigationController = UINavigationController(rootViewController: viewController)    navigationController.modalPresentationStyle = .fullScreen    present(navigationController, animated: true)}

Objective-C

UIViewController *viewController = [Zendesk.instance.messaging messagingViewController];if (viewController != NULL) {    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];    navigationController.modalPresentationStyle = UIModalPresentationFullScreen;    [self presentViewController:navigationController animated:YES completion:nil];}

Choose the appropriate modalPresentationStyle for your app's UX. The .fullScreen style is recommended for a dedicated conversation experience.

Property list keys

Add the following keys to enable camera, microphone, and photo library access:

  • NSCameraUsageDescription - allows access to the device’s camera for images and videos.
  • NSMicrophoneUsageDescription - allows access to the device’s microphone for use when capturing videos with the camera.
  • NSPhotoLibraryUsageDescription - allows read and write access in photo library (iOS14+).

SDK size

The size of the Zendesk SDK for iOS after installation will vary depending on your integration method, selected features, and build settings. As a general guideline:

  • XCFramework download size: Approximately 7.5 MB (may vary by version)
  • App size impact: The final impact on your app’s size may be smaller due to app thinning, bitcode stripping, and linker optimizations.
  • Dependency impact: Additional dependencies (such as ZendeskSDKCoreUtilities, ZendeskSDKUIComponents, etc.) may increase the total size.

Migrating from Classic or Sunshine Conversations SDK?

If you are migrating from the Classic SDK or Sunshine Conversations SDK, please refer to the dedicated migration guides for best practices, side-by-side integration, and troubleshooting:

Next steps