apache / cordova-plugin-dialogs

Apache Cordova Dialogs Plugin
https://cordova.apache.org/
Apache License 2.0
289 stars 354 forks source link

CB-8773: Fix for iOS 8 keyboard not appearing on prompt #50

Closed cjpearson closed 8 years ago

sean-hill commented 9 years ago

:+1:

dirkpostma commented 7 years ago

I still suffer from keyboard not appearing on prompt, this fix doesn't seem to work for me. I tried to debug, but couldn't find the cause. I tried setting a breakpoint in didPresentAlertView in file CDVNotification.m, but the method is never executed.

The keyboard appears, but disappears immediately.

More info:

iPhone 7 iOS 10.2 cordova-plugin-dialogs 1.3.1 Cordova CLI: 6.3.1 OS: Mac OS X El Capitan Node Version: v5.0.0 Xcode version: Xcode 8.2.1 Build version 8C1002

dirkpostma commented 7 years ago

For ionic users who suffer the same problem, I found a workaround by applying a 500ms timeout. It's bad UX because of the delay, but at least the keyboard is not dismissed anymore.

    function promptIOS(message, title, value) {
        return $timeout(function() {
            return $cordovaDialogs.prompt(_.defaults(message, ""), _.defaults(title, "Type een omschrijving"), ['Cancel', 'OK'], value)
                .then(function(result) {
                    var input = result.input1;
                    // no button = 0, 'Cancel' = 1, 'OK' = 2
                    var buttonIndex = result.buttonIndex;

                    if (buttonIndex == 2) {
                        // OK pressed
                        return $q.resolve(result.input1);
                    } else {
                        // Cancel
                        return $q.reject("user pressed cancel");
                    }
                });
            }, 500);
    }