我有一個與DevExpress和PhoneGap開發的混合應用程序。iOS上的PhoneGap應用程序中的window.open:此應用程序不允許查詢方案文件
我試着通過
window.open('file:///var/mobile/Containers/Data/.../image.jpg', '_system');
打開本地JPEG圖像,但它不工作(再)iPhone和iPad(最新的iOS版本9),與錯誤error: "This app is not allowed to query for scheme file"
失敗。
(該應用程序通過PhoneGap的方法FileTransfer.download
來,它通過window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, ...)
方法得到的文件夾中下載的圖像事先)
它正常工作在Android,它在iPhone上,以及在幾個星期前工作正常。由於DevExtreme的更新,我認爲它可能與PhoneGap更新有關。
之前,我用PhoneGap 3.7.0,現在我用cli-5.2.0。
我已經找到這個問題(https://www.devexpress.com/Support/Center/Question/Details/Q486439),這個問題是相似的,但它已經2歲了,似乎並沒有解決我的問題。
使用GapDebug,我看到這個在日誌中:
<Warning>: THREAD WARNING: ['InAppBrowser'] took '38.211914' ms. Plugin should use a background thread.
<Warning>: THREAD WARNING: ['File'] took '26.509033' ms. Plugin should use a background thread.
<Warning>: -canOpenURL: failed for URL: "file:///var/mobile/Containers/Data/Application/9425CCB6-77F7-4337-B37C-7DB577C2F6B4/Documents/myDocuments/a96e7238-a502-49e6-bcd3-186937afc3cb/camera_1458208164206.jpg" - error: "This app is not allowed to query for scheme file"
這是某種權限的問題,但什麼添加到config.xml?
這是我的config.xml:
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" id="com.devexpress.apptemplate" version="1.0" versionCode="1">
<name>ApplicationTemplate</name>
<preference name="phonegap-version" value="cli-5.2.0" />
<preference name="permissions" value="none" />
<preference name="prerendered-icon" value="true" />
<preference name="android-windowSoftInputMode" value="adjustResize" />
<preference name="SplashScreen" value="splash" />
<preference name="SplashScreenDelay" value="60000" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="DisallowOverscroll" value="true" />
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#000000" />
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
<feature name="http://api.phonegap.com/1.0/network" />
<gap:plugin name="com.devexpress.plugins.devextremeaddon" version="1.0.1" />
<gap:plugin name="cordova-plugin-ios-longpress-fix" version="1.1.0" source="npm" />
<gap:plugin name="org.apache.cordova.camera" version="0.3.6" />
<gap:plugin name="org.apache.cordova.file" version="1.3.3" />
<gap:plugin name="org.apache.cordova.file-transfer" version="0.5.0" />
<gap:plugin name="org.apache.cordova.inappbrowser" version="0.6.0" />
<gap:plugin name="org.apache.cordova.media-capture" version="0.3.6" />
<gap:plugin name="org.apache.cordova.media" version="0.2.16" />
<gap:plugin name="org.apache.cordova.network-information" version="0.2.15" />
<gap:plugin name="cordova-plugin-statusbar" version="2.1.0" source="npm" onload="true" />
<gap:plugin name="org.apache.cordova.splashscreen" version="1.0.0" onload="true" />
<access origin="*" subdomains="true"/>
<gap:plugin name="cordova-plugin-whitelist" source="npm"/>
<allow-navigation href="*" />
<allow-intent href="*" />
</widget>
我甚至增加了兩行
<allow-navigation href="*" />
<allow-intent href="*" />
根據https://github.com/apache/cordova-plugin-whitelist,並沒有幫助。
我看到離子,另一種混合架構,還提到了自己的文檔http://docs.ionic.io/docs/cordova-whitelist可能存在權限問題與新的PhoneGap版本,如CLI版本,並且,上述<allow-navigation href="*" />
應使用 - 但它似乎並沒有幫助我的情況。
===更新===
我創建了的PhoneGap的&科爾多瓦的github上兩張票:
- https://github.com/phonegap/phonegap-app-developer/issues/413
- https://issues.apache.org/jira/browse/CB-11027
===更新2 ===
如以下建議,我現在使用https://github.com/pwlin/cordova-plugin-file-opener2而不是,它工作正常。
我面臨同樣的問題.. 。我開始使用cordova-plugin-file-opener2(https://github.com/pwlin/cordova-plugin-file-opener2)來避免這個問題。 – gmartini20
@ gmartini20謝謝,這也適用於我:) –
@ gmartini20你會讓你的評論一個答案?順便說一句:file-opener2插件似乎有問題,其中有空格的文件路徑 - window.open()不。 –