I'm currently working on a hybrid app using Cordova and Angular. My goal is to prevent users from scrolling when the keyboard is open.
Although the cordova keyboard plugin from ionic, ionic-plugin-keyboard, offers events for both opening and closing the keyboard, I've encountered an issue where the event for keyboard closure never triggers.
In my angular run script (within app.run(function...), I have included the following code:
document.addEventListener('native.keyboardshow', keyboardShowHandler);
function keyboardShowHandler(e){
alert("keyboard open"); //This alert doesn't appear
$cordovaKeyboard.disableScroll(true);
}
window.addEventListener('native.keyboardhide', keyboardHideHandler);
function keyboardHideHandler(e){
alert("keyboard closed"); //This alert works as intended
$cordovaKeyboard.disableScroll(false);
}
The 'native.keyboardshow' event handler does not function, while the 'native.keyboardhide' event consistently triggers.
After researching online, I found information suggesting that the app should not be in Fullscreen mode. I tried adding the following line to my config.xml:
<preference name="Fullscreen" value="false" />
However, this did not resolve the issue, even after experimenting with setting the value to true as well. Has anyone else encountered this problem? My Cordova version is 6.0.0.