我有一个使用cordova 构建的应用程序,但我不知道如何添加退出/停止功能来退出应用程序。在谷歌和其他网站上环顾四周后,我得到了使用的线索,navigator.app.exitApp()但它对我不起作用。我该如何解决这个问题?
这是我的代码:
function onDeviceReady() {
var network = navigator.connection.type;
if (network === 'none') {
$cordovaDialogs.confirm('Attention' + '\n' + 'You have no internet connection', '', ['Review Settings', 'Exit'])
.then(function(buttonIndex) {
// no button = 0, 'OK' = 1, 'Cancel' = 2
var btnIndex = buttonIndex;
if (btnIndex == 1) {
$state.go('register');
} else {
navigator.device.exitApp();
}
});
Run Code Online (Sandbox Code Playgroud) cordova ×1