Help Lightning API Documentation / Tutorials / Using the Miniview with the iOS SDK

Using the Miniview with the iOS SDK

This document is the tutorial to enable the screen sharing feature.

  1. Create a new target in your Xcode project, using the template of `Broadcast Upload Extension`.

    Please make sure the broadcast extension is embeded in the host app.

  2. You might need to set `CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER` = NO and `ENABLE_USER_SCRIPT_SANDBOXING` = NO for the broadcast extension target in order to make Cocoapods work properly.
  3. Add a target for the new broadcast extension in your Podfile.
    target 'BroadcastExtension' do
        pod 'HLSDK/ScreenSharing', '17.6.1'
    end
    

    Run pod install to update the dependencies for the broadcast extension

  4. Create an app group and add the broadcast extension and the host app to the app ground


  5. Change the SampleHandler to inherit from `HLScreenSharingBroadcastSampleHandler`
    #import <ReplayKit/ReplayKit.h>
    #import <HLSDKScreenSharing/HLSDKScreenSharing.h>
    @interface SampleHandler : HLScreenSharingBroadcastSampleHandler
    @end
    

    Remove all the generated empty methods in SampleHandler and overwrite getAppGroupName to return the app group name. If the app group name isn’t correct, the screen sharing feature will not work properly

    #import "SampleHandler.h"
    @implementation SampleHandler
    - (NSString*)getAppGroupName {
        return @"group.com.helplightning.sdk.SampleObjC.BroadcastExtension";
    }
    @end
    
  6. In the host app code, implement this new delegate in `HLClientDelegate`. The delegate method should return a dictionary with two keys:
    - (NSDictionary*) hlCallNeedScreenSharingInfo:(id<HLGenericCall>)call {
        return @{
            kHLCallPluginScreenSharingAppGroupName: @"group.com.helplightning.sdk.SampleObjC.BroadcastExtension",
            kHLCallPluginScreenSharingBroadcastExtensionBundleId:  @"com.helplightning.sdk.SampleObjC.BroadcastExtension"
        };
    }
    
    • `kHLCallPluginScreenSharingAppGroupName` is the app group name shared by the host app and the broadcast extension
    • `kHLCallPluginScreenSharingBroadcastExtensionBundleId` is the bundle id of the broadcast extension
  • The app is ready to be deployed to iOS devices (The broadcast extension isn't available on iOS simulators). There are two ways to start screen sharing.
    • Method 1: In-Call Share Menu -> Screen


    • Method 2: Add `Screen Recording` to iOS Control Center.

      Choose the broadcast extension to start recording

      If users try to start screen sharing when there is no active HL call, the broadcast will be stopped automatically in a few seconds.