Skip to content
This repository was archived by the owner on Feb 20, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Basic-Video-Chat/Basic-Video-Chat/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ @interface ViewController ()<OTSessionDelegate, OTSubscriberDelegate, OTPublishe
@property (nonatomic) OTSession *session;
@property (nonatomic) OTPublisher *publisher;
@property (nonatomic) OTSubscriber *subscriber;
@property (nonatomic, strong) UITapGestureRecognizer *tapGestureRecognizer;

@end

@implementation ViewController
Expand All @@ -39,6 +41,31 @@ - (void)viewDidLoad
sessionId:kSessionId
delegate:self];
[self doConnect];

self.tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[self.view addGestureRecognizer:self.tapGestureRecognizer];
}

- (void)handleTap:(UITapGestureRecognizer *)recognizer {
NSLog(@"View controller was tapped!");
[self enableTorch:YES];
}

- (void)enableTorch:(BOOL)enabled {
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if (!device || !device.hasTorch) {
return;
}

NSError *error = nil;
[device lockForConfiguration:&error];
if (error) {
NSLog(@"Error locking device for configuration: %@", error);
return;
}

device.torchMode = enabled ? AVCaptureTorchModeOn : AVCaptureTorchModeOff;
[device unlockForConfiguration];
}

- (BOOL)prefersStatusBarHidden
Expand Down