0

我正在使用 Onsen 2 和 Monaca 创建带有 scandit 扫描仪的条形码扫描仪应用程序。我将扫描库集成为插件 cordova plugin add 。在 Android 和 iPad 上一切正常,但对于 iOS 10+,它表现出奇怪的行为。只有在我按下手机的主页按钮并很快将应用程序恢复到前台后,相机才会打开,扫描仪工作正常。

我发现这里已经问过一个类似的问题,但这里还没有答案。 Onsen 2 - Monaca CLI - Cordova 插件奇怪的行为

请在标记重复之前重新考虑我的问题,因为问题仍然存在。

下面是我的代码

scan() {
    
        console.log('............scan clicked...........');
        
    (<any>window).Scandit.License.setAppKey(“xxxxxxxxxxxxxxxxxxxxx”);
        var settings = new (<any>window).Scandit.ScanSettings();
        settings.setSymbologyEnabled((<any>window).Scandit.Barcode.Symbology.EAN13, true);
        settings.setSymbologyEnabled((<any>window).Scandit.Barcode.Symbology.UPC12, true);
        settings.setSymbologyEnabled((<any>window).Scandit.Barcode.Symbology.EAN8, true);
        var picker = new (<any>window).Scandit.BarcodePicker(settings);
        picker.show(success, null, failure);
    
        function success(session) {
            alert("Scanned " + session.newlyRecognizedCodes[0].symbology + " code: " + session.newlyRecognizedCodes[0].data);
    
    
            session.stopScanning();
    
        }
        function manual(content) {
    
            ons.notification.alert("Manual: " + content);
    
        }
        function failure(error) {
            ons.notification.alert("Failed: " + error);
    
        }
    
        picker.startScanning();
    
    
    }

任何帮助表示感谢谢谢

4

1 回答 1

0

更改“index.html”中的 <meta>

<meta http-equiv="Content-Security-Policy" content="img-src * 'self' data:; default-src * 'self' gap: wss: ws: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval';">

它对我有用

感谢拇指

https://forum.ionicframework.com/t/cordova-inappbrowser-plugin-stopped-working-in-ios-10/64361/8

于 2017-03-03T11:08:39.823 回答