在 Cordova/PhoneGap 应用程序中增加超时以摆脱 "The server is taking longer than expected to respond"

Increasing timeout to get rid of "The server is taking longer than expected to respond" in a Cordova/PhoneGap app

我正在为 iOS 和 Android 应用程序使用 Cordova/PhoneGap。应用程序所做的只是在 onDeviceReady () 函数中调用 "window.location.replace" 以将浏览器重定向到外部站点。从那时起,"app" 只需使用 Cordova/PhoneGap 的内置浏览器即可处理所有内容(而不是 InAppBrowser)。

我发现的一件事是,当服务器可能 运行 比平常慢一点时,我有时会收到此弹出窗口:

弹出窗口出现得太早,通常只出现几秒钟。正如我所说,这发生在 iOS 和 Android.

是否可以将 Cordova/PhoneGap 浏览器中的超时时间增加到更高的值(例如 60 秒)?如果那不可能,是否可以完全阻止此弹出窗口显示?

谢谢。

我自己设法解决了这个问题。

出现的 "Connection Error" 弹出窗口不是核心 Cordova/PhoneGap 代码的一部分,但它实际上是 cordova-plugin-remote-injection 的一部分。它有一个默认设置为 10 秒后显示该弹出窗口:

CRIPageLoadPromptInterval

<preference name="CRIPageLoadPromptInterval" value="5" />

Type: int

Default: 10

If the site hasn't loaded after this interval the user will be provided a choice to continue waiting or to retry loading the site. This is turned on by default. If not wanting the prompt the user set the value to 0.

在您的 config.xml 文件中将此值设置为更大的数字(例如,如果您想要 1 分钟的超时,则设置为 60)可以解决问题。我已通过将值设置为 1 秒超时并看到弹出窗口不断出现来确认这一点。

我希望这对以后可能遇到同样问题的其他人有所帮助。