Cordova应用程序在iOS 10启动时挂起

时间:2023-02-06 04:02:25

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 beta(以防它是模拟器问题),但我得到了相同的结果。

The app works fine on iOS 9.3 (both device and Simulator).

该应用程序在iOS 9.3(设备和模拟器)上运行良好。

Anyone encountered/fixed this problem?

有人遇到/解决了这个问题吗?

UPDATE

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
  • 在执行上述切换之前,某些插件将无法正常工作

2 个解决方案

#1


70  

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.

希望这有助于其他人。

#2


1  

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标记

#1


70  

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.

希望这有助于其他人。

#2


1  

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标记