Screen Share


Contents

1. Screen Sharing Warm Up

2. Screen Sharing Setup

1. Screen Sharing Warm Up

The screen sharing feature is a little bit tricky in iOS due to the strict screen capturing policies from Apple. You will need to manually set up and activate the screen sharing feature.

Before we start configuring, please ensure you have the following:

  • A valid Apple developer account
  • A valid Apple provision file that supports App Groups

2. Screen Sharing Setup

  1. Assume you have an existing project, the first thing you need to do is to enable App Group feature in project configurations:
Turn "Off" to "On"
Turn "Off" to "On"

Then, assign a valid App Groups to the project.

  1. After that, create a new Target and select Broadcast Upload Extension, this new target will be our extension for screen sharing.

Note: Please create a new target when testing this with our demo app, using the existing MobileRTCSampleScreenShare will not work

  1. Navigate to the didFinishLaunchingWithOptions method where you initialize Zoom SDK in AppDelegate.m, and set the App Group name:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSLog(@"%@", paths[0]);
    
    MainViewController *mainVC = [[[MainViewController alloc] init] autorelease];
    UINavigationController *navVC = [[[UINavigationController alloc] initWithRootViewController:mainVC] autorelease];
    navVC.navigationBarHidden = YES;
    
    self.window.rootViewController = navVC;
    
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    // SDK init
    [[[SDKInitPresenter alloc] init] SDKInit:navVC];
    
    [[[SDKAuthPresenter alloc] init] SDKAuth];
    
    //5. Set AppGroup name
    //Note: This step is optional, Method is uesd for iOS Replaykit Screen share integration,if not,just ignore this step.
    [[MobileRTC sharedRTC] setAppGroupsName:@"Your App Group ID here"];
    return YES;
}
  1. Enable the App Group feature in your extension and assign group name:
  1. Set up the App Group name in SampleHandler.m, and copy the sample code from SampleHandler.m to your iOS app.
#import "SampleHandler.h"
#import <MobileRTCScreenShare/MobileRTCScreenShareService.h>

@interface SampleHandler () <MobileRTCScreenShareServiceDelegate>

@property (strong, nonatomic) MobileRTCScreenShareService * screenShareService;

@end

@implementation SampleHandler

- (instancetype)init
{
    self = [super init];
    if (self)
    {
        MobileRTCScreenShareService * service = [[MobileRTCScreenShareService alloc]init];
        self.screenShareService = service;
        self.screenShareService.appGroup = @"Your App Group ID here";
        self.screenShareService.delegate = self;
        [service release];
    }
    return self;
}

- (void)dealloc
{
    self.screenShareService = nil;
    [super dealloc];
}


- (void)broadcastStartedWithSetupInfo:(NSDictionary<NSString *,NSObject *> *)setupInfo {
    // User has requested to start the broadcast. Setup info from the UI extension can be supplied but optional.
        [self.screenShareService broadcastStartedWithSetupInfo:setupInfo];
    
}

- (void)broadcastPaused {
        [self.screenShareService broadcastPaused];
    // User has requested to pause the broadcast. Samples will stop being delivered.
}

- (void)broadcastResumed {
        [self.screenShareService broadcastResumed];
    // User has requested to resume the broadcast. Samples delivery will resume.
}

- (void)broadcastFinished {
    // User has requested to finish the broadcast.
        [self.screenShareService broadcastFinished];
}

- (void)processSampleBuffer:(CMSampleBufferRef)sampleBuffer withType:(RPSampleBufferType)sampleBufferType {
    [self.screenShareService processSampleBuffer:sampleBuffer withType:sampleBufferType];
}

- (void)MobileRTCScreenShareServiceFinishBroadcastWithError:(NSError *)error
{
    [self finishBroadcastWithError:error];
}

@end
  1. Add MobileRTCScreenShare framework as the build dependency.
  1. In the end, implement the method onClickShareScreen and response to delegate to enable screen sharing feature:
/*!
 @brief Callback event that user clicks the sharing screen.
 @param parentVC Parent viewcontroller to present the view of Sharing Screen Usage Guide.
 @waring Application will present Share Screen Usage Guide.
 */
- (void)onClickShareScreen:(UIViewController*)parentVC;

Once you have the meeting up and running, follow the instruction in the following link to activate the Broadcasting Services on your phone:

By pressing “Start Broadcast” on the application with Zoom SDK, you will be able to start sharing your screen.

Going back to your meeting view, you will see your screen sharing has been activated.