Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 12 additions & 3 deletions ios/IdscanSdk.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@ @implementation IdscanSdk
[[NSUserDefaults standardUserDefaults] synchronize];

dispatch_async(dispatch_get_main_queue(), ^(void) {
ScannerViewController* scannerViewController = [[ScannerViewController alloc] init];
ScannerViewController *scannerViewController = [[ScannerViewController alloc] init];
scannerViewController.delegate = self;
NSLog(@"IDScanner: Starting camera scanner...");

UIViewController *rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];

UIWindow *windowRoot = nil;
NSArray *windows = [[UIApplication sharedApplication] windows];
for (UIWindow *window in windows) {
if (window.isKeyWindow) {
windowRoot = window;
break;
}
}

UIViewController *rootViewController = [windowRoot rootViewController];
[rootViewController presentViewController:scannerViewController animated:YES completion:nil];
});
}
Expand Down
11 changes: 8 additions & 3 deletions ios/ScannerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ - (void)initCapture

// We add the preview layer
self.prevLayer = [AVCaptureVideoPreviewLayer layerWithSession: self.captureSession];

UIWindow *firstWindow = [[[UIApplication sharedApplication] windows] firstObject];
UIWindowScene *windowScene = firstWindow.windowScene;
UIInterfaceOrientation orientation = windowScene.interfaceOrientation;

UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (orientation == UIInterfaceOrientationLandscapeLeft) {
self.prevLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeLeft;
self.prevLayer.frame = CGRectMake(0, 0, MAX(self.view.frame.size.width,self.view.frame.size.height), MIN(self.view.frame.size.width,self.view.frame.size.height));
Expand Down Expand Up @@ -485,8 +488,10 @@ - (void)decodeResultNotification: (NSNotification *)notification {
}

- (enum UIInterfaceOrientationMask)supportedInterfaceOrientations {
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];

UIWindow *firstWindow = [[[UIApplication sharedApplication] windows] firstObject];
UIWindowScene *windowScene = firstWindow.windowScene;
UIInterfaceOrientation interfaceOrientation = windowScene.interfaceOrientation;

switch (interfaceOrientation) {
case UIInterfaceOrientationPortrait:
return UIInterfaceOrientationMaskPortrait;
Expand Down