MobileChromeApps / mobile-chrome-apps

Chrome apps on Android and iOS
BSD 3-Clause "New" or "Revised" License
2.5k stars 347 forks source link

Cordova Dialogs callback delay #376

Open MGMsystems opened 10 years ago

MGMsystems commented 10 years ago

I'm using a prompt from Cordova dialogs. http://plugins.cordova.io/#/package/org.apache.cordova.dialogs When I Click a button on the prompt, the dialog dismisses but my callback function is not called. If I then click another random action in my app, my callback function from the prompt is called. When I run the app in a plain Cordova app everything works as it should. The callback function is being executed when I press a button on the prompt. It's like callbackContext.sendPluginResult from the dialog plugin doesn't work? Or is not being done until an other action is called.

mmocny commented 10 years ago

This sounds like a bridge bug, maybe? Or perhaps the main thread is blocked for some reason?

If you could provide some sample code that reproduces the issue, that would be much appreciated.

@agrieve as an fyi.

MGMsystems commented 10 years ago
  $cordovaDialogs.confirm('Are you sure?', 'Confirm',['Ok','Cancel']).then(function(results) {

            if(results==1) {
                $cordovaDialogs.prompt('Give a comment.', 'Comment',['Ok','Cancel'],'').then(function(results) {
                    if(results.buttonIndex ==1) {
                        console.log(results);
                        $cordovaDialogs.alert('Action done','Done');
                    } else {
                        $cordovaDialogs.alert('Action cancelled','Cancelled');
                    }
                });
            }
        });

I'm using ngCordova here, but it also happens when I use Cordova dialogs without ngCordova.

mmocny commented 10 years ago

I just tried this snipped (based on yours):

navigator.notification.confirm('Are you sure?', function(results) {
  if (results != 1) return;
  navigator.notification.prompt('Give a comment.', function(results) {
    if (results.buttonIndex == 1) {
      navigator.notification.alert('Action done', function() {}, 'Done');
    } else {
      navigator.notification.alert('Action cancelled', function() {}, 'Cancelled');
    }
  }, 'Comment', ['Ok','Cancel'], '');
}, 'Confirm', ['Ok','Cancel']);

Works fine both inside a cca app (dialogs show and callbacks called as would be expected).

Perhaps its specific to the ngCordova wrapper, or more likely your application (perhaps some blocking js is executing?). When you ran inside the vanilla cordova app, did you include your entire app or just a simple case?