iOS

The Help Lightning iOS SDK is an Objective-C/Swift SDK that allows Help Lightning calls to be embedded into your iOS application.

Prerequisites

Before you can use the SDK, you must have an API Key which requires a Help Lightning site with an Enterprise Tier.

Installing the SDK

The SDK is available via Help Lightning’s Cocoapods Repo.

You can also download the iOS SDK from the following links:

Installation Instructions for Objective-C

Example Podfile:

platform :ios, '14.0'
install! 'cocoapods', :disable_input_output_paths => true
# ignore all warnings from all pods
inhibit_all_warnings!
use_modular_headers!

source 'https://github.com/VIPAAR/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'

target 'SampleObjC' do
  pod 'HLSDK', 17.8.0'
  #Override the deployment targets of all pods
  post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
      end
    end
  end
end

Installation Instructions for Swift

Import HLSDK and HLSDKSwift.

import HLSDKCommon
import HLSDK
import HLSDKSwift

Example Podfile

platform :ios, '14.0'
install! 'cocoapods', :disable_input_output_paths => true
use_modular_headers!

source 'https://github.com/VIPAAR/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'

target 'SampleSwift' do
  pod 'HLSDKSwift', 17.8.0'

  # this line is important to make PromiseSwift work
  pod 'PromisesObjC', '2.0.0', :modular_headers => true

  #Override the deployment targets of all pods
  post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
      end
    end
  end
end

Using the SDK

To use the SDK, you will need to implement the HLClientDelegate interface. The following shows this in ObjC, but is also supported using Swift.

#import <HLSDKCommon/HLSDKCommon.h>
#import <HLSDK/HLSDK.h>

@interface CallController () <HLClientDelegate>
...
@end

In your implementation, set our interface as the delegate to the HL Client

@implementation CallController

- (void)viewDidLoad {
  [super viewDidLoad];
  
  HLClient.sharedInstance.delegate = self;
}

#program mark - Help Lightning HLClientDelegate

- (void) hlCall:(HLCall*)call didEndWithReason:(NSString*)reason {
  NSLog(@"The call has ended");
}

@end

Then you need to create an HLCall object. This should have all the necessary tokens and URLs of the server to join. This information is obtained by interacting with the server’s RESTful API to create a call/session between users. Typically, this is handled by your integration server.

- (void)joinCall {
  ...
  
  HLCall* call = [[HLCall alloc] initWithSessionId:sessionId,
                                      sessionToken:sessionToken,
                                         userToken:userToken,
                                            gssUrl:url,
                                helpLightingAPIKey:apiKey,
                              localUserDisplayName:displayName,
                                localUserAvatarUrl:avatarUrl,
                                  autoEnableCamera:YES,
                              autoEnableMicrophone:YES];
                                
  FBLPromise* promise = [HLClient.sharedInstance startCall: call withPresentingViewController:self];
  [promise then:^id(id callId) {
    NSLog(@"The call has started");
    return callId;
  }];
  [promise catch:^(NSError* error) {
    NSLog(@"Cannot start call: %@", error);
  }];
}

Full Examples

Help Lightning maintains a working example in both ObjC and Swift. Please read through the documentation in the top level of the repository as it is necessary run the sample integration server!

Screen Sharing

Here is a turtorial to add the screen sharing feature to an app, using Help Lightning iOS SDK:

iOS Screen Sharing Tutorial