ios 注意
1、如果是cordova 5.0 及以上版本都要安装一个白名单插件
cordova plugins add cordova-plugin-whitelist
2、iOS9出现的问题
在iOS9以后的app中,都建议使用HTTPS协议,而我们使用cordova创建iOS应用后,并没有注意到这一点继续使用HTTP协议发现无法正常使用。
解决方法:在项目的info.plist中添加一个Key:NSAppTransportSecurity,类型为字典类型。然后给它添加一个Key:NSAllowsArbitraryLoads,类型为Boolean类型,值为YES。这样我们就可以继续使用HTTP协议来请求数据了。
无法 create
使用 cordova@6.0.0 create
之后使用最新 cordova 添加平台
Failed to install the following Android SDK packages as some licences have not been accepted.
cd /d D:\android-environment\androidsdk/tools/bin
sdkmanager --licenses
# 如果报错 Error: Unknown argument --licenses
sdkmanager --update
之后 accept yes
无法访问外部 url
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<!-- 配置请求外部 url -->
<allow-navigation href="http://*/*" />
接口请求无效
在Android高版本对非加密的明文传输有要求,也即默认启用了TLS保护,使得该应用无法进行http网络请求,而https则不会受影响,同样地,如果应用嵌套了webview也会受这限制。
针对该问题:
在 platforms/android/app/src/main/AnroidManifest.xml
中的 application
添加设置项:
<application android:usesCleartextTraffic="true">
Error Network , error ‘ERR_FILE_NOT_FOUND(file:///android_assets/www/index.html)’
Check the internet connection permission is added in manifest file. If it’s not, Add the code in your manifest file.
<config-file parent="/manifest" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<!-- Internet Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Network State Permissions -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</config-file>
Cannot find plugin.xml for plugin “xxx”. Please try adding it again.
手动删除 plugins>xxx 文件,之后运行
cordova plugins remove xxx
cordova plugins add xxx
iframe 网页在 ios 不显示
在 index.html 里添加一个meta标签(复制即可)
<meta http-equiv="Content-Security-Policy" content="default-src *; frame-src *; style-src * 'self' 'unsafe-inline' 'unsafe-eval'; script-src * 'self' 'unsafe-inline' 'unsafe-eval';">
在 config.xml 里添加以下东西(复制即可,如果有重复的,删掉即可)
<access origin="*" subdomains="true" />
<allow-navigation href="*" />
版权声明:本文为lucky541788原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。