Can't use the appShareWithView

Hey @lemon97213,

I apologize for the delay, I am still working on this.
Stay tuned.

Thanks!
Michael

Hey @lemon97213,

I wrote up some pretty basic code that should help out. Here is how to use it:

  1. Fill out the information at the top of the VC. There is appGroupID, JWT, Meeting Number, and Meeting Password.
  2. Start a meeting with waiting room and screensharing enabled using a Zoom client. I used my mac client.
  3. Run the application with that meeting’s number and password input into the VC.
  4. You will see 3 views: Red is going to be your local view stream, blue is the remote stream, and green is going to be the view you will share.
  5. Click the join meeting button.
  6. Admit the user on the Zoom Client machine.
  7. Observe the 2 video streams now show your local device stream and the remote users stream.
  8. Click the “Start app share button”
  9. Wait a few seconds, and if all went well you should see the green view show up on your Zoom Client.

I wrote this on a handset device so the views might be small for you, but you can change the size to whatever youd like. Here is the code:

//
//  ViewController.m
//  AppShareWithViewExample
//
//  Created by Michael Condon on 9/22/21.
//

#import "ViewController.h"

@interface ViewController ()

@property (nonatomic)  UIView* localView;
@property (nonatomic)  UIView* remoteView;
@property (nonatomic)  UIView* shareView;
@property (nonatomic)  UILabel* waitingRoomLabel;
@property (nonatomic)  UIButton* joinMeetingButton;
@property (nonatomic)  UIButton* startAppShareButton;

@end

@implementation ViewController

NSString* appGroupId = @"";
NSString* JWT = @"";
NSString* meetingNumber = @"";
NSString* meetingPassword = @"";


- (void)loadView {
    [super loadView];
    
    [self initializeSDK];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setupViews];
}


- (void)initializeSDK {
    MobileRTCSDKInitContext *initContext = [[MobileRTCSDKInitContext alloc] init];
    initContext.appGroupId = appGroupId;
    initContext.domain = @"https://zoom.us";
    
    if ([[MobileRTC sharedRTC] initialize:initContext] == YES) {
        MobileRTCAuthService* authService = [[MobileRTC sharedRTC] getAuthService];
        if (!authService) {
            return;
        }
        
        authService.jwtToken = JWT;
        authService.delegate = self;
        
        [authService sdkAuth];
    }
}


- (void)setupViews {
    CGFloat screenCenterX = self.view.center.x - 50;
    
    UIView *localView = [[UIView alloc] initWithFrame:CGRectMake(screenCenterX, 0, 100, 100)];
    localView.backgroundColor = [UIColor redColor];
    [[self view] addSubview:localView];
    self.localView = localView;
    
    UIView *remoteView = [[UIView alloc] initWithFrame:CGRectMake(screenCenterX, 100, 100, 100)];
    remoteView.backgroundColor = [UIColor blueColor];
    [[self view] addSubview:remoteView];
    self.remoteView = remoteView;
    
    UIView *shareView = [[UIView alloc] initWithFrame:CGRectMake(screenCenterX, 200, 100, 100)];
    shareView.backgroundColor = [UIColor greenColor];
    [[self view] addSubview:shareView];
    self.shareView = shareView;
    
    UIButton *joinMeetingButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [joinMeetingButton addTarget:self
               action:@selector(joinMeeting:)
     forControlEvents:UIControlEventTouchUpInside];
    [joinMeetingButton setTitle:@"Join Meeting" forState:UIControlStateNormal];
    joinMeetingButton.frame = CGRectMake(screenCenterX, 300, 100, 50);
    [[self view] addSubview:joinMeetingButton];
    self.joinMeetingButton = joinMeetingButton;
    
    UILabel *waitingRoomLabel = [[UILabel alloc] initWithFrame:CGRectMake(screenCenterX, 350, 300, 100)];
    waitingRoomLabel.text = @"Not yet in meeting.";
    [[self view] addSubview:waitingRoomLabel];
    self.waitingRoomLabel = waitingRoomLabel;
    
    UIButton *startAppShareButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [startAppShareButton addTarget:self
                          action:@selector(startAppShare:)
     forControlEvents:UIControlEventTouchUpInside];
    [startAppShareButton setTitle:@"Start app share" forState:UIControlStateNormal];
    startAppShareButton.frame = CGRectMake(screenCenterX, 400, 100, 50);
    [[self view] addSubview:startAppShareButton];
    self.startAppShareButton = startAppShareButton;
}

- (void)joinMeeting:(UIButton*)sender {
    MobileRTCMeetingService *meetService = [[MobileRTC sharedRTC] getMeetingService];
    MobileRTCMeetingSettings *meetSettings = [[MobileRTC sharedRTC] getMeetingSettings];

    if (!meetService) {
        return;
    }
    if (!meetSettings) {
        return;
    }
    
    meetService.delegate = self;
    meetService.customizedUImeetingDelegate = self;
    
    MobileRTCMeetingJoinParam *joinParams = [[MobileRTCMeetingJoinParam alloc] init];
    joinParams.meetingNumber = meetingNumber;
    joinParams.password = meetingPassword;
    joinParams.userName = @"ios sdk";
    
    meetSettings.enableCustomMeeting = YES;
    
    MobileRTCMeetError joinMeetingReturnValue = [meetService joinMeetingWithJoinParam:joinParams];
    if (joinMeetingReturnValue == MobileRTCMeetError_Success) {
        NSLog(@"Joining meeting");
    } else {
        NSLog(@"Failed to join meeting");
    }
}

- (void)showAttendeeVideos {
    MobileRTCVideoView *localVideoView = [[MobileRTCVideoView alloc] initWithFrame:self.localView.bounds];
    [localVideoView setVideoAspect:MobileRTCVideoAspect_PanAndScan];
    [self.localView addSubview:localVideoView];
    NSUInteger myUserID = [[[MobileRTC sharedRTC] getMeetingService] myselfUserID];
    [localVideoView showAttendeeVideoWithUserID:myUserID];
    
    NSArray *inMeetingParticipants = [[[MobileRTC sharedRTC] getMeetingService] getInMeetingUserList];
    NSUInteger otherUserID = 0;
    for (NSNumber *currentUserID in inMeetingParticipants) {
        if ([currentUserID unsignedIntegerValue] != myUserID) {
            otherUserID = [currentUserID unsignedIntegerValue];
            break;
        }
    }
    
    if (otherUserID == 0) {
        return;
    }
        
    MobileRTCVideoView *remoteVideoView = [[MobileRTCVideoView alloc] initWithFrame:self.remoteView.bounds];
    [remoteVideoView setVideoAspect:MobileRTCVideoAspect_PanAndScan];
    [self.remoteView addSubview:remoteVideoView];
    [remoteVideoView showAttendeeVideoWithUserID:otherUserID];
}


- (void)startAppShare:(UIButton*)sender {
    MobileRTCMeetingService *meetService = [[MobileRTC sharedRTC] getMeetingService];

    if (!meetService) {
        return;
    }
    
    if (meetService.isStartingShare) {
        [meetService stopAppShare];
    } else {
        [meetService startAppShare];
        ViewController* __weak weakSelf = self;
        dispatch_async(dispatch_get_main_queue(), ^{
            ViewController* strongSelf = weakSelf;
            if (strongSelf) {
                [meetService appShareWithView:strongSelf.shareView];
            }
        });
    }
}


// #pragma mark - MobileRTCAuthDelegate

- (void)onMobileRTCAuthReturn:(MobileRTCAuthError)returnValue {
    switch (returnValue) {
        case MobileRTCAuthError_Success:
            NSLog(@"SDK Authed");
            break;
            
        default:
            NSLog(@"Could not auth SDK.");
            break;
    }
}

// #pragma mark - MobileRTCMeetingServiceDelegate

- (void)onMeetingError:(MobileRTCMeetError)error message:(NSString *)message {
    switch (error) {
        case MobileRTCMeetError_Success:
            break;
            
        default:
            NSLog(@"MobileMeetError: %lu", (unsigned long)error);
    }
}

- (void)onWaitingRoomStatusChange:(BOOL)needWaiting {
    if (needWaiting == YES) {
        NSLog(@"In waiting room...");
        if (!_waitingRoomLabel) {
            return;
        }
        
        _waitingRoomLabel.text = @"in waiting room";
    } else {
        NSLog(@"Left waiting room.");
        if (!_waitingRoomLabel) {
            return;
        }
        
        _waitingRoomLabel.text = @"Left waiting room";
        
        [self showAttendeeVideos];
    }
}

- (void)onJoinMeetingConfirmed {
    NSLog(@"Joined meeting.");
}

- (void)onJoinMeetingInfo:(MobileRTCJoinMeetingInfo)info completion:(void (^)(NSString * _Nonnull, NSString * _Nonnull, BOOL))completion {
    NSLog(@"Invalid meeting credentials");
}

- (void)onJBHWaitingWithCmd:(JBHCmd)cmd {
    switch (cmd) {
        case JBHCmd_Show:
            NSLog(@"Joined before host.");
            break;
            
        default:
            break;
    }
}

- (void)onDestroyMeetingView {
    return;
}

- (void)onInitMeetingView {
    return;
}

@end

Lemme know if you have any questions.

Thanks!
Michael

Hi @Michael_Condon ,

I don’t have appgroupID, since I think only screen share need to have it , if I only share the view also need it too?

Hey @lemon97213,

You can leave that one as a blank string.

Thanks!
Michael

Hi @Michael_Condon ,

I am facing new problem now. Although The appshare problem still exist.

I created object
MobileRTCMeetingStartParam4WithoutLoginUser * user = [[MobileRTCMeetingStartParam4WithoutLoginUser alloc]init] ;

But In the new version( MobileRTC Version: 5.7.1 (644)) the userToken param is missing.

What should I do?

Thanks,
Alex

Also The new demo app have no response while I click in any button expevt “Join a meeting”, but after i have enter the meeting no. and pwd.

Hey @lemon97213,

To keep the threads organized, can you open a new post with the token issue?

Thanks!
Michael

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.