# Can't use the appShareWithView

**URL:** <https://devforum.zoom.us/t/cant-use-the-appsharewithview/56311>\
**Category:** iOS\
**Created:** [August 24, 2021, 3:40am UTC](https://devforum.zoom.us/t/cant-use-the-appsharewithview/56311 "2021-08-24T03:40:18Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![Michael\_Condon](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_condon/32/13543_2.png) [@Michael\_Condon](https://devforum.zoom.us/u/Michael_Condon)\
**Post date:** [September 20, 2021, 8:59pm UTC](https://devforum.zoom.us/t/cant-use-the-appsharewithview/56311/21 "2021-09-20T20:59:02Z")

</div>

Hey @lemon97213,

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

Thanks!  
Michael

---

<div class="post-metadata">

**Author:** ![Michael\_Condon](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_condon/32/13543_2.png) [@Michael\_Condon](https://devforum.zoom.us/u/Michael_Condon)\
**Post date:** [September 23, 2021, 10:35pm UTC](https://devforum.zoom.us/t/cant-use-the-appsharewithview/56311/22 "2021-09-23T22:35:03Z")

</div>

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:

```auto
//
// 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

---

<div class="post-metadata">

**Author:** ![lemon97213](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lemon97213/32/30378_2.png) [@lemon97213](https://devforum.zoom.us/u/lemon97213)\
**Post date:** [September 24, 2021, 2:03am UTC](https://devforum.zoom.us/t/cant-use-the-appsharewithview/56311/23 "2021-09-24T02:03:24Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Michael\_Condon](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_condon/32/13543_2.png) [@Michael\_Condon](https://devforum.zoom.us/u/Michael_Condon)\
**Post date:** [September 24, 2021, 5:02pm UTC](https://devforum.zoom.us/t/cant-use-the-appsharewithview/56311/24 "2021-09-24T17:02:55Z")

</div>

Hey @lemon97213,

You can leave that one as a blank string.

Thanks!  
Michael

---

<div class="post-metadata">

**Author:** ![lemon97213](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lemon97213/32/30378_2.png) [@lemon97213](https://devforum.zoom.us/u/lemon97213)\
**Post date:** [September 30, 2021, 7:05am UTC](https://devforum.zoom.us/t/cant-use-the-appsharewithview/56311/25 "2021-09-30T07:05:48Z")

</div>

Hi @Michael_Condon ,

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

 ![Screenshot 2021-09-30 at 3.00.31 PM](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/5/7/575ae50a74f77200f57f626fad8b29c46c06c22d.png)

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

---

<div class="post-metadata">

**Author:** ![lemon97213](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lemon97213/32/30378_2.png) [@lemon97213](https://devforum.zoom.us/u/lemon97213)\
**Post date:** [September 30, 2021, 10:06am UTC](https://devforum.zoom.us/t/cant-use-the-appsharewithview/56311/26 "2021-09-30T10:06:14Z")

</div>

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.

 ![IMG_0059](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/b/5/b5176b5b20e6fb8ba8cd53da8f95681bbe44e3dc.png)

---

<div class="post-metadata">

**Author:** ![Michael\_Condon](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_condon/32/13543_2.png) [@Michael\_Condon](https://devforum.zoom.us/u/Michael_Condon)\
**Post date:** [September 30, 2021, 5:39pm UTC](https://devforum.zoom.us/t/cant-use-the-appsharewithview/56311/27 "2021-09-30T17:39:48Z")

</div>

Hey @lemon97213,

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

Thanks!  
Michael

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [October 31, 2021, 3:40am UTC](https://devforum.zoom.us/t/cant-use-the-appsharewithview/56311/28 "2021-10-31T03:40:44Z")

</div>

Closed on October 31, 2021, 3:40am UTC

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

[Previous page](https://devforum.zoom.us/t/cant-use-the-appsharewithview/56311.md?page=1)
