1

I am running this using phonegap. When i run in Android the logout box is correct and its showing "confirm" as title in the logout box. Even in ios everything is perfect but the logout box shows title as "index.html"(which is the current page name)

                         $rootScope.logout=function()
                        {

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

I dont want the title as "index.html". Can you suggest a method to not display the title as "index.html"

Amrutha Jaya Raj
  • 612
  • 2
  • 10
  • 32

1 Answers1

1

In ios PhoneGap pages will show the page name in alert, you need to use a plugin for notification. To add the plugin run this code.

cordova plugin add cordova-plugin-dialogs

Usage

navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels])
  • message: Dialog message. (String)
  • confirmCallback: Callback to invoke with index of button pressed (1, 2, or 3) or when the dialog is dismissed without a button press (0). (Function)
  • title: Dialog title. (String) (Optional, defaults to Confirm)
  • buttonLabels: Array of strings specifying button labels. (Array) (Optional, defaults to [OK,Cancel])

Example

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
);

The callback takes the argument buttonIndex (Number), which is the index of the pressed button. Note that the index uses one-based indexing, so the value is 1, 2, 3, etc.

Documentation

Now its working fine,

$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']
    );
}
byteC0de
  • 5,153
  • 5
  • 33
  • 66