xcode Cordova 应用程序在 iOS 10 上启动时挂起
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38410159/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cordova app hanging during startup on iOS 10
提问by DaveAlden
I just installed Xcode 8 beta in order to test my existing Cordova app in iOS 10 beta (via Simulator). When the app is launched, it just hangs on the loading page - seems the deviceready
event is not being fired.
我刚刚安装了 Xcode 8 beta,以便在 iOS 10 beta(通过模拟器)中测试我现有的 Cordova 应用程序。当应用程序启动时,它只是挂在加载页面上 - 似乎deviceready
没有触发事件。
So I also installed iOS 10 beta on my iPad Air (just in case it's a Simulator issue), but I get the same results.
所以我还在我的 iPad Air 上安装了 iOS 10 测试版(以防万一它是模拟器问题),但我得到了相同的结果。
The app works fine on iOS 9.3 (both device and Simulator).
该应用程序在 iOS 9.3(设备和模拟器)上运行良好。
Anyone encountered/fixed this problem?
有没有人遇到/解决过这个问题?
UPDATE
更新
Other symptoms of this problem include:
此问题的其他症状包括:
- the app will start correctly if you background the app (switch back to the home screen) then foreground the app (switch back to the app)
- some plugins will not work correctly until you do the above switching
- 如果您将应用程序置于后台(切换回主屏幕)然后将应用程序置于前台(切换回应用程序),则该应用程序将正确启动
- 在您进行上述切换之前,某些插件将无法正常工作
回答by DaveAlden
OK, I found the problem and the solution thanks to this post:
好的,由于这篇文章,我找到了问题和解决方案:
It seems that iOS 10 requires additional entries in the Content-Security-Policy
meta tag, namely gap:
and file:
. After adding these, my Content-Security-Policy
looks like this:
似乎 iOS 10 需要在Content-Security-Policy
元标记中添加额外的条目,即gap:
和file:
。添加这些后,我的Content-Security-Policy
样子是这样的:
<meta http-equiv="Content-Security-Policy" content="default-src * gap: file:; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src * 'unsafe-inline' 'unsafe-eval'">
And the app starts up and works fine on iOS 10.
该应用程序在 iOS 10 上启动并运行良好。
Hope this helps others.
希望这对其他人有帮助。
回答by user2981810
I had the same problem during startup, and even if I did do a double tap on the home button and back to the app, cordova's file system wouldn't write to the device.
我在启动过程中遇到了同样的问题,即使我双击主页按钮并返回到应用程序,cordova 的文件系统也不会写入设备。
I tried a lot of things, but finally fixed it by adding
我尝试了很多东西,但最终通过添加来修复它
child-src * gap://ready
to the Content-Security-Policy tag
到 Content-Security-Policy 标签