javascript iPhone 无法识别 PhoneGap 的 navigator.app

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14422908/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 21:36:48  来源:igfitidea点击:

iPhone does not recognize PhoneGap's navigator.app

javascriptiphonehtmlcordova

提问by Hodaya Shalom

I have a button to exit from the application. The function looks like this:

我有一个按钮可以退出应用程序。该函数如下所示:

//Close application
function close_window() {
  navigator.app.exitApp();
}

It did not work, so I tried the following line:

它没有用,所以我尝试了以下行:

navigator.device.exitApp();

It did not work either. Then I discovered by alert that the iPhone does not recognize PhoneGap's navigator.app and navigator.device. I use PhoneGap version 2.2.0.

它也不起作用。然后我通过警报发现 iPhone 无法识别 PhoneGap 的 navigator.app 和 navigator.device。我使用 PhoneGap 2.2.0 版。

Why is this happening?

为什么会这样?

P.S.: It works for me on Android.

PS:它适用于我在 Android 上。

回答by Gajotres

navigator.app.exitApp()does not work on IOS, only Android. On iOS, Apple does not allow apps to programmatically exit.

navigator.app.exitApp()不适用于 IOS,仅适用于 Android。在 iOS 上,Apple 不允许应用程序以编程方式退出。

It can be done through iOS objective c side but there's a good chance this app will be rejected in Apple app store.

它可以通过 iOS 目标 c 端完成,但这个应用程序很有可能在 Apple 应用程序商店中被拒绝。

Here you will find a good explanation: https://groups.google.com/forum/?fromgroups=#!topic/phonegap/XjTm0ua4uOY.

在这里你会找到一个很好的解释:https: //groups.google.com/forum/?fromgroups=#! topic/phonegap/ XjTm0ua4uOY