pas autorisé à charger l'application de ressources locales ios9 cordova

<!--CSP Meta Tags in index.html --> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no"> <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline' 'unsafe-eval'; script-src 'self' 'unsafe-inline' 'unsafe-eval';"> <title>Test App</title> </head> <!-- config.xml file with whitelist plugin --> <?xml version="1.0" encoding="utf-8" ?> <widget xmlns = "http://www.w3.org/ns/widgets" xmlns:gap = "http://phonegap.com/ns/1.0" id = "com.abc.testApp" versionCode = "10" version = "2.0.0" > <name>TestApp</name> <description> Sample app to download and launch hybrid app </description> <author email="[email protected]" href="http://1ct.es"> Test </author> <preference name="orientation" value="portrait" /> <preference name="fullscreen" value="true" /> <preference name="webviewbounce" value="false" /> <icon src="icon.png" /> <content src="index.html" /> <gap:platform name="ios" /> <gap:plugin name="cordova-plugin-whitelist" source="npm" /> <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.5.2" /> <gap:plugin name="org.chromium.zip" version="2.1.0" /> <gap:config-file platform="ios" parent="NSAppTransportSecurity"> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> </gap:config-file> <allow-navigation href="*" /> <allow-intent href="*" /> <access origin="*" /> </widget> 

C'est la partie de l'extrait de code pour get le path local de l'application et charger le path dans un iframe:

 var appLocalUrl = cordova.file.dataDirectory + AppId + "/index.html"; iframe[0].contentWindow.location.replace(appLocalUrl); 

L'application est téléchargée sur le path local, mais lorsque nous essayons de lancer ceci dans iframe, le message d'erreur est arrivé:

pas autorisé à charger la ressource locale: {file: ///var/mobile/Containers/Data/Application/B8BF6DE2-228D-46B9-A84D-D2122D152385/Library/NoCloud/970/index.html}

Toute aide à ce sujet?

Donc, j'ai déjà beaucoup de mal à ce sujet. La dernière version d'iOS utilise WKWebView. Il semble traiter les files locaux comme s'ils provenaient d'un server distant, même s'ils se trouvaient dans l'application elle-même, et de telles requests sont bloquées. Source de reference

La solution suivante a fonctionné pour moi:

  1. Ajoutez le plugin de file Corodova.

    cordova plugin add cordova-plugin-file

  2. Changez le path d'access du file local à ceci:

    cdvfile://localhost/bundle/www/you_folder_name/file_name.mp3