Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Alert Handlers

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

Mike6580064
Posts: 0
Joined: Wed Jan 15, 2014 6:00 pm

Alert Handlers

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?

Mike6580064
Posts: 0
Joined: Wed Jan 15, 2014 6:00 pm

Alert Handlers

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');
}
}

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Alert Handlers

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

Mike6580064
Posts: 0
Joined: Wed Jan 15, 2014 6:00 pm

Alert Handlers

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.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Alert Handlers

Hello,

Please add code below on the online handler:
pre

localStorage.removeItem("offline");
/pre

Mike6580064
Posts: 0
Joined: Wed Jan 15, 2014 6:00 pm

Alert Handlers

Alena,

What do you mean by online handler?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Alert Handlers

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

Mike6580064
Posts: 0
Joined: Wed Jan 15, 2014 6:00 pm

Alert Handlers

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

localStorage.removeItem("offline");

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Alert Handlers

Yes.

Return to “Issues”