Page 2 of 5

Alert Handlers

Posted: Wed Jun 04, 2014 1:43 pm
by Evgene Karachevtsev

Mike,

You can create javascript handler for button "login":

codeif (localStorage.getItem('offline') == 'true'){
navigator.notification.alert(
'You are the winner!', // message
alertDismissed, // callback
'Game Over', // title
'Done' // buttonName
);
}else{
loginService.execute(....
} /code


Alert Handlers

Posted: Wed Jun 04, 2014 2:59 pm
by Mike6580064

Thanks guys.

The problem I have now is that on login button click (while OFFLINE) my incorrect password alert fires AS WELL AS the no connection alert. How can I disable the incorrect password alert if offline?


Alert Handlers

Posted: Wed Jun 04, 2014 8:13 pm
by Mike6580064

To be clear, I am running the following JS on a login service error:

navigator.notification.alert(
"Incorrect username and/or password",
callBackFunctionB,
'Login Error'
);
function callBackFunctionB(){
console.log('OK');
}

On the Login page Offline event I'm running the following JS:

navigator.notification.alert(
"Your device has no connectivity",
callBackFunctionB,
'Connection Required'
);
function callBackFunctionB(){
console.log('OK');
}

...and setting a LSV "offline" that's bound to my login button.

On my login button click I am invoking my login service as well as running the following JS:

if ("offline" in localStorage){
navigator.notification.alert(
"Your device has no connectivity",
callBackFunctionB,
'Connection Required'
);
function callBackFunctionB(){
console.log('OK');
}
}


Alert Handlers

Posted: Thu Jun 05, 2014 2:18 am
by Yurii Orishchuk

Hi Mike.

You need add to your code on "error" event this code:

precode

//If offline - return and alert user about it
if ("offline" in localStorage)
return alert("Connection broken");

//You code
navigator.notification.alert("Your device has no connectivity",
callBackFunctionB, 'Connection Required');

function callBackFunctionB() {
console.log('OK');
}

/code/pre

Regards


Alert Handlers

Posted: Thu Jun 05, 2014 12:43 pm
by Mike6580064

Yurii,

WITH connection and an incorrect password, both alerts fire now.

I need to tell it that if "offline" is in localStorage, DON'T fire the incorrect password alert.


Alert Handlers

Posted: Thu Jun 05, 2014 6:11 pm
by Alena Prykhodko

Hello,

Please add code below on the online handler:
pre

localStorage.removeItem("offline");
/pre


Alert Handlers

Posted: Thu Jun 05, 2014 6:38 pm
by Mike6580064

Alena,

What do you mean by online handler?


Alert Handlers

Posted: Thu Jun 05, 2014 6:45 pm
by Alena Prykhodko

It's Online PhoneGap event. You can find more about Events here. http://devcenter.appery.io/documentat...


Alert Handlers

Posted: Thu Jun 05, 2014 6:51 pm
by Mike6580064

So I'm creating an Online Event and running the following code only?

localStorage.removeItem("offline");


Alert Handlers

Posted: Thu Jun 05, 2014 7:13 pm
by Alena Prykhodko

Yes.