android - 如何在 iOS 移动应用程序中显示注销警告框

标签 android angularjs mobile-application phonegap

我正在使用 phonegap 运行它。当我在 Android 中运行时,注销框是正确的,并且在注销框中显示“确认”作为标题。即使在 ios 中,一切都很完美,但注销框显示标题为“index.html”(这是当前页面名称)

                         $rootScope.logout=function()
                        {

                  response=confirm(GetLocalString("HMLOGOUTMSG",_language));
                            if(response==true)
                            {
                                logout();
                            }
                            else
                            {
                                menuchk();
                            }
                        }

我不希望标题为“index.html”。你能建议一种不将标题显示为“index.html”的方法

最佳答案

在ios中PhoneGap页面会在alert中显示页面名称,需要使用插件进行通知。 要添加插件,请运行此代码。

cordova plugin add cordova-plugin-dialogs

用法

navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels])
  • message:对话消息。 (字符串)
  • confirmCallback:在按下按钮索引时调用的回调 (1, 2 或 3) 或在没有按下按钮的情况下关闭对话框时 (0)。 (功能)
  • title:对话框标题。 (字符串)(可选,默认为确认)
  • buttonLabels:指定按钮标签的字符串数组。 (大批) (可选,默认为[确定,取消])

例子

function onConfirm(buttonIndex) {
    alert('You selected button ' + buttonIndex);
}

navigator.notification.confirm(
    'You are the winner!', // message
     onConfirm,            // callback to invoke with index of button pressed
    'Game Over',           // title
    ['Restart','Exit']     // buttonLabels
);

回调采用参数 buttonIndex (Number),这是按下的按钮的索引。注意索引使用的是从一开始的索引,所以取值为1、2、3等。

Documentation

现在它工作正常,

$rootScope.logout = function () {
    function onConfirm(buttonIndex) {
        if (buttonIndex == 1) {
            logoutfunc();
        }
        else {
            menuopenchk();
        }
    }

    navigator.notification.confirm(
        'Are you sure to logout?',
        onConfirm,
        'Logout',
        ['Yes', 'Not Now']
    );
}

关于android - 如何在 iOS 移动应用程序中显示注销警告框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45433713/

相关文章:

android - 在运行时改变方向

jquery - 根据移动应用程序的屏幕尺寸自动增大字体大小

ios - 每次启动移动应用程序时,我都应该在网络服务中检查用户身份验证(用户名、密码、设备 token )吗?

android -\intermediates\proguard-rules\release\aapt_rules.txt(系统找不到指定的路径)

android - 如何为我的企业应用程序定价?

java - 如何使用服务器刷新身份验证 token

angularjs - 一个输入字段上有多个 ng 模型?

javascript - 如何在 $http.post 上追加文件?

jquery - 我可以在 Angular js中的其他 Controller 中使用 Controller 吗?

api - string' 不是 'int' 类型 'index' 的子类型,同时将 api 数据提取到 ListView 中。 flutter