iOS Custom UI Quickstart (APAC)

A quick guide for installing, initializing, and authenticating users

Installation

The first step to any integration is installing the BrandMessenger framework.

Our preferred installation method is Cocoapods. You can find detailed steps for doing so in the Automated Installation Using Cocoapods guide.

One you have installed the framework using CocoaPods, add the code snippet below in the application's Podfile and run pod install.

source 'https://github.com/CocoaPods/Specs'
     use_frameworks!  # Required to add 
     platform :ios, '12.0' # Required to add

        target 'TARGET_NAME' do
        pod 'BrandMessenger', :git => '[email protected]:lithiumtech/ios-brandmessenger-sdk-dist.git', :tag => '1.9.0'
  # Required to add 
     end

Authentication

Prior to sending the first message, the user requires authentication. This is a two-step process.

First, initialize the SDK with the Company Key and App ID as shown below. Contact Khoros Support for your Company Key and App ID if you do not have them.

@import BrandMessengerUI

// Call it only once in your app.
[[BrandMessengerManager alloc] initWithCompanyKey: @"<COMPANY KEY>", applicationKey: @"<APP ID>"];// Replace this with your Company Key and App ID
import BrandMessengerUI

// Call it only once in your app.
BrandMessengerManager(companyKey: "<COMPANY KEY>", applicationKey: "<APP ID>") // Replace this with your Company Key and App ID

Next, register the user following the example below.

[BrandMessengerManager login:@"accessToken" completion:^(KBMRegistrationResponse * _Nullable response, NSError * _Nullable error) {
        
    if (error != nil) {
        NSLog(@"BrandMessenger login failed with an error: %@", error.localizedDescription);
        return;
    }
        
    NSLog(@"BrandMessenger login successful");
}];
BrandMessengerManager.login("accessToken") { response, error in

     if let err = error {
          print("BrandMessenger login failed with an error: ", err.localizedDescription)
          return
     }
     
     print("BrandMessenger login successful")
}

The logged-in user can then open a conversation with an agent.

[BrandMessengerManager show:viewController];
// or
[BrandMessengerManager show:nil];
BrandMessengerManager.show(viewController)
// or
BrandMessengerManager.show()

This will present the conversation screen from the supplied viewController, or if not provided, will look for the top view controller and present from there.

🚧

To receive app notifications Push notification setup is required.


Did this page help you?