From 4b3a5abe38d7fe2c7c156ca5fb8767fd916552f1 Mon Sep 17 00:00:00 2001 From: EddyVerbruggen Date: Tue, 10 Sep 2019 21:25:53 +0200 Subject: [PATCH] [iOS] Custom navigation vanishes after camera was opened #220 --- CHANGELOG.md | 2 +- src/barcodescanner.ios.ts | 11 ++++++++--- src/package.json | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53e06cd..c4e4b83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [3.3.0](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/3.3.0) (2019-09-10) +## [3.3.1](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/3.3.1) (2019-09-10) [Full Changelog](https://github.com/EddyVerbruggen/nativescript-barcodescanner/milestone/43?closed=1) diff --git a/src/barcodescanner.ios.ts b/src/barcodescanner.ios.ts index f435356..512d34e 100644 --- a/src/barcodescanner.ios.ts +++ b/src/barcodescanner.ios.ts @@ -89,7 +89,7 @@ export class BarcodeScanner { private _audioSession: AVAudioSession; private _closeCallback: any; private _device: AVCaptureDevice; - private _lastScanOptions: ScanOptions; + private _lastScanViewController: UIViewController; constructor() { if (typeof AVAudioSession.sharedInstance().setCategoryModeOptionsError === "function") { @@ -192,7 +192,12 @@ export class BarcodeScanner { public stop(): Promise { return new Promise((resolve, reject) => { try { - this.getViewControllerToPresentFrom(this._lastScanOptions ? this._lastScanOptions.presentInRootViewController : false).dismissViewControllerAnimatedCompletion(true, null); + if (this._lastScanViewController) { + this._lastScanViewController.dismissViewControllerAnimatedCompletion(true, null); + this._lastScanViewController = undefined; + } else { + this.getViewControllerToPresentFrom().dismissViewControllerAnimatedCompletion(true, null); + } this._removeVolumeObserver(); this._closeCallback && this._closeCallback(); resolve(); @@ -217,7 +222,6 @@ export class BarcodeScanner { this._addVolumeObserver(); arg = arg || {}; - this._lastScanOptions = arg; let closeButtonLabel = arg.cancelLabel || "Close"; let isContinuous = typeof arg.continuousScanCallback === "function"; @@ -347,6 +351,7 @@ export class BarcodeScanner { viewController = UIApplication.sharedApplication.keyWindow.rootViewController; } + this._lastScanViewController = viewController; return viewController; } } diff --git a/src/package.json b/src/package.json index 9b13b8e..0dcb4e0 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-barcodescanner", - "version": "3.3.0", + "version": "3.3.1", "description": "Scan QR/barcodes with your NativeScript app.", "main": "barcodescanner", "typings": "index.d.ts",