Help Lightning API Documentation / SDKs / Clients / iOS SDK 17.x (Deprecated)

iOS SDK 17.x (Deprecated)

This guide describes the deprecated 17.x CocoaPods integration. For SDK 26.5.3, use the current iOS SDK guide.

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 repository.

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 HLSDKCommon, 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;
}

#pragma 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
                               helplightningAPIKey: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

The current screen-sharing tutorial applies to SDK 26.5.3 and is not compatible with this CocoaPods integration. For 17.x:

  1. Add a Broadcast Upload Extension target and embed it in the host app.

  2. Add the legacy screen-sharing pod to that target:

    target 'BroadcastExtension' do
      pod 'HLSDK/ScreenSharing', '17.8.0'
    end
    
  3. Add the same App Group capability to the host app and extension.

  4. Make the extension handler inherit from HLScreenSharingBroadcastSampleHandler and return that App Group:

    #import <HLSDKScreenSharing/HLSDKScreenSharing.h>
    
    @implementation SampleHandler
    
    - (NSString *)getAppGroupName {
      return @"group.com.example.MyApp.BroadcastExtension";
    }
    
    @end
    
  5. Return the App Group and extension bundle identifier from the host application’s HLClientDelegate:

    - (NSDictionary *)hlCallNeedScreenSharingInfo:
        (id<HLGenericCall>)call {
      return @{
        kHLCallPluginScreenSharingAppGroupName:
          @"group.com.example.MyApp.BroadcastExtension",
        kHLCallPluginScreenSharingBroadcastExtensionBundleId:
          @"com.example.MyApp.BroadcastExtension"
      };
    }
    

Test the extension on a physical iPhone or iPad. The archived SampleObjC and SampleSwift projects remain the reference for this legacy integration.