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

Using the Miniview with the Xamarin SDK

This document is the tutorial to enable the screen sharing feature, using Xamarin iOS SDK

  1. Create a broadcast extension in the solution of the main app, using the template of `Broadcast Upload Extension`

  2. The template will generate two projects in the solution: `BroadcastExtension` and `BroadcastExtensionUI`. We don't need `BroadcastExtensionUI` and we can safely delete it

  3. Remove `MovieClipHandler.cs` in `BroadcastExtension`
  4. Create an App Group. Add it to `Entitlement.plist` of `BroadcastExtension` and the entitlement of the main app, so that the main app and the broadcast extension can share screen sharing data
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    	<key>com.apple.security.application-groups</key>
    	<array>
    		<string>[your app group name]</string>
    	</array>
    </dict>
    </plist>
    
  5. Change `NSExtensionPointIdentifier` in `Info.plist` of `BroadcastExtension`:
    	<dict>
    		<key>NSExtensionPointIdentifier</key>
    		<string>com.apple.broadcast-services-upload</string>
    		<key>NSExtensionPrincipalClass</key>
    		<string>SampleHandler</string>
    		<key>RPBroadcastProcessMode</key>
    		<string>RPBroadcastProcessModeSampleBuffer</string>
    	</dict>
    
  6. Add HelpLightning.SDK.iOS.Binding.ScreenSharing.[version].nupkg to the project of `BroadcastExtension`.
    DON'T add `HelpLightning.SDK.[version].nupkg`to the project of `BroadcastExtension`

  7. Edit `SampleHandler.cs` in `BroadcastExtension` to remove all methods generated by the template. Make `SampleHandler` inherit from `HelpLightning.SDK.iOS.Binding.ScreenSharing.HLScreenSharingBroadcastSampleHandler` and override the readonly property 'AppGroupName'. `AppGroupName` should return the App Group shared by the broadcast extension and the main app.
    using System;
    using Foundation;
    
    namespace BroadcastExtension
    {
        [Register("SampleHandler")]
        public class SampleHandler : HelpLightning.SDK.iOS.Binding.ScreenSharing.HLScreenSharingBroadcastSampleHandler
        {
    		protected SampleHandler (IntPtr handle) : base (handle)
    		{
    		}
            public override string AppGroupName => "[your app group name]";
        }
    }
    
  8. There is a new delegate method, `CallNeedScreenSharingInfo(Call call)`, for screen sharing in `ICallClientDelegate`. The main app should implement it, otherwise, screen sharing will not be enabled. The delegate method should return a dictionary with two entries: The value of `CallClientDelegateConstants.BroadcastExtensionAppGroupName` should be the App Group for the broadcast extension. The value of `CallClientDelegateConstants.BroadcastExtensionBundleId` should be the broadcast extension's bundle id.
    public IDictionary<string, object> CallNeedScreenSharingInfo(Call call)
    {
        return new Dictionary<string, object>
        {
            { CallClientDelegateConstants.BroadcastExtensionAppGroupName, "[your app group name]" },
            { CallClientDelegateConstants.BroadcastExtensionBundleId, "[your broadcast extension bundle id] },
        };
    }
    
  9. 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 your 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.