Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-12248

navigator.notification.confirm callback doesn't return an index but a boolean

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: cordova-cli@6.4.0
    • Fix Version/s: None
    • Component/s: cordova-plugin-dialogs
    • Labels:
      None
    • Environment:

      OS: Ubuntu_16_LTS x86_64, Kernel Version: 4.4.0-31-generic, Browser: Google Chrome 54.0.2840.71 (stable), Framework: MobileFirst 8

      Description

      Since the buttonIndex should return an integer, the following code should be working but the default case is always fired:

          navigator.notification.confirm("Description",
              function (buttonIndex) {
                  switch(buttonIndex){
                      case:1
                          //do something
                          break;
                      default:
                          //do something
                  }
              }
          }, "Title", ["OK", "Cancel"]);
      

      A little inspection reveal that the confirm method is returning a boolean instead of a number. The following code is working:

          navigator.notification.confirm("Description",
              function (buttonIndex) {
                  if(buttonIndex){
                      //do something
                  }else{
                      //do something
                  }
              }
          }, "Title", ["OK", "Cancel"]);
      

      The documentation states "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." and it should be changed accordingly.

        Attachments

          Activity

            People

            • Assignee:
              jcesarmobile jcesarmobile
              Reporter:
              apasi Alessandro Pasi
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: