Hello, I am experimenting with cordovaPinDialog (ng-cordova wrapper version) and when the application resumes from the background, I am asking the user to re-enter the PIN.
However, it looks like the event handle is not passed back to me - the only things passed back in the ‘result’ variable is the text (PIN) and which button was pressed.
So I can’t call ‘preventDefault’ (or similar, as I assume this is a native dialog) if the password is wrong. What is the best way to not exit the dialog box if the password is wrong? do/while does not work as this is a promise.
Here is my resume code
document.addEventListener("resume", function () {
ZMDataModel.zmLog("App is resuming from background");
ZMDataModel.validatePin()
.then ( function(data)
{
// do rest of app resume
});
}, false);
Here is my validatePIN code:
validatePin: function()
{
var d=$q.defer();
if (loginData.usePin)
{
zmDebug("Validating PIN...");
var pinMatch = false;
$cordovaPinDialog.prompt ('Enter PIN', 'PIN Confirm', ["OK"])
.then( function (result)
{
if (result.input1 != loginData.pinCode)
{
displayBanner("error",["Invalid PIN. Please try again"]);
zmLog("Invalid PIN entered...");
// **** How do I prevent the dialog box from exiting here ?
d.resolve(false);
}
else
{
pinMatch = true;
zmLog("Valid PIN entered");
d.resolve(true);
}
},
function (error)
{
zmLog("PIN error handler. Should not come here");
d.resolve(false);
});
return (d.promise);
}
else
{
zmDebug("No PIN set, skipping");
}
},