Skip to content

Commit

Permalink
The plugin may crash your app on iOS with NativeScript 4 #158
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Jun 14, 2018
1 parent d61c433 commit f6c888a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
19 changes: 7 additions & 12 deletions src/barcodescanner.ios.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {BarcodeScannerView as BarcodeScannerBaseView, ScanOptions, ScanResult} from "./barcodescanner-common";
import * as utils from "tns-core-modules/utils/utils";
import * as frame from "tns-core-modules/ui/frame";

export class BarcodeScannerView extends BarcodeScannerBaseView {

Expand Down Expand Up @@ -157,7 +156,7 @@ export class BarcodeScanner {
public stop(): Promise<any> {
return new Promise((resolve, reject) => {
try {
let app = utils.ios.getter(UIApplication, UIApplication.sharedApplication);
const app = utils.ios.getter(UIApplication, UIApplication.sharedApplication);
app.keyWindow.rootViewController.dismissViewControllerAnimatedCompletion(true, null);
this._removeVolumeObserver();
this._closeCallback && this._closeCallback();
Expand Down Expand Up @@ -241,17 +240,13 @@ export class BarcodeScanner {
this._device.unlockForConfiguration();
}

let topMostFrame = frame.topmost();
if (topMostFrame) {
let vc = topMostFrame.currentPage && topMostFrame.currentPage.ios;
if (vc) {
vc.presentViewControllerAnimatedCompletion(this._scanner, true, () => {
if (arg.torchOn) {
this._enableTorch();
}
});
const app = utils.ios.getter(UIApplication, UIApplication.sharedApplication);
app.keyWindow.rootViewController.presentViewControllerAnimatedCompletion(this._scanner, true, () => {
if (arg.torchOn) {
this._enableTorch();
}
}
});

} catch (ex) {
console.log("Error in barcodescanner.scan: " + ex);
reject(ex);
Expand Down
2 changes: 1 addition & 1 deletion src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-barcodescanner",
"version": "2.7.6",
"version": "2.7.7",
"description": "Scan QR/barcodes with your NativeScript app.",
"main": "barcodescanner",
"typings": "index.d.ts",
Expand Down

0 comments on commit f6c888a

Please sign in to comment.