2016-10-26 64 views
0

對於我正在開發的項目,必須有掃描QR碼的方法。我從phonegap-plugin-barcodescanner得到這個。因爲它在Android上運行良好,從來沒有任何問題。Phonegap插件barcodescanner在iOs上崩潰

但是在iOs上,它會按原樣崩潰。您將收到使用相機的請求,然後應用程序崩潰。我在這發現的方式是刪除它的選項部分,然後它的工作。

這看起來像是一種奇怪的方式來解決它。 問題:有沒有更好的方法來解決這個問題?

cordova.plugins.barcodeScanner.scan(
    function (result) { 
     alert("We got a barcode\n" + 
      "Result: " + result.text + "\n" + 
      "Format: " + result.format + "\n" + 
      "Cancelled: " + result.cancelled); 
    }, 
    function (error) { 
     alert("Scanning failed: " + error); 
    }, 
    { 
     "preferFrontCamera" : true, // iOS and Android 
     "showFlipCameraButton" : true, // iOS and Android 
     "prompt" : "Place a barcode inside the scan area", // supported on Android only 
     "formats" : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED 
     "orientation" : "landscape" // Android only (portrait|landscape), default unset so it rotates with the device 
    } 
); 

使用:視窗10,英特爾XDK v3619,科爾多瓦CLI 6.2.0和PhoneGap的-插件,barcodescanner 4.1.0

+0

對不起,我提出一個啞巴解決方案,但它爲我工作...對我來說,崩潰發生在Android上,我做的是:我刪除了android平臺(科爾多瓦plartform RM Android),定義最新的科爾多瓦CLI進行編譯(curren tly 6.4.0)。實際上構建失敗了,所以我回到了以前爲我工作的CLI(6.1.1),並重新添加了android平臺(cordova platform add android)。然後,miracuosly開始工作,並停止崩潰。嘗試平臺「ios」。也可以爲你工作。 – Lentyai

回答

2

我也對IOS 10科爾多瓦 - 插件 - barcodescanner崩潰問題通過Phonegap構建。

嘗試小時後,現在解決了,我不得不添加科爾多瓦 - 插件相機第一,然後科爾多瓦 - 插件 - barcodescanner

以下是有關提取物我工作的config.xml:

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

 
<plugin name="cordova-plugin-camera" spec="~2.3.1"> 
 
<variable name="CAMERA_USAGE_DESCRIPTION" value="My App would like to access your camera, to take photos of your documents." /> 
 
</plugin> 
 

 
<preference name="android-build-tool" value="gradle" /> 
 

 
<plugin name="cordova-plugin-barcodescanner"> 
 
<variable name="CAMERA_USAGE_DESCRIPTION" value="abc123" /> 
 
</plugin>

在這兩個Android6和IOS10 GitHub上的例子是現在的工作很好:https://github.com/phonegap/phonegap-plugin-barcodescanner