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

Alert Handlers

When I attempt to login to my app with my device's network connection off, I get the alert of a login error that still tells me that the reason I can't log in is because of an incorrect username or password (the alert I set up on a login error), when the real reason is because of a connectivity error. I have two questions:

1) Can I allow access to the app even without being connected to a network/wifi?

2) If not, can I make the alert notify the user that there is no connectivity to their device (instead of receiving an incorrect username/password alert when it's really a connectivity issue)? Can this alert fire as soon as the app is launched if there is no connection detected?

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

Alert Handlers

Hello Mike,

1) Appery.io login service uses REST API it supposes to use the internet connection.
2) You should use "Online" and "Offline" events to handle internet connection action.

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

Alert Handlers

Evgene,

Please explain how I would use "Online" and Offline" events. Would I invoke JS on page load of my login page?

Thanks,
Mike

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

Alert Handlers

Evgene,

I've added an Offiline event on my login page that successfully fires an alert when the page loads. However, I'd still like to fire the alert when the user attempts to click the login button if there is no connection. Is this possible?

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

Alert Handlers

Also, I would like to change the default title of the alert. Currently it's showing the name of my page "Login.html"

I tried the following to no avail. What am I doing wrong?

alert ("Incorrect Username and/or Password", {
title:"Login Error"});

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Alert Handlers

Hi Mike,

1) On Offline/Online events save a localStorage variable with values "offline"/"online" accordingly. On button click check it and display a message if it equals "offline".

2) Use the following codealert()/code:
http://docs.phonegap.com/en/3.0.0/cor...

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

Alert Handlers

Katya,

I've set a LSV on an offline event and bound it to my login button. On button click am I running JS? I'm not sure of the proper command to use here...

Thanks,
Mike

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Alert Handlers

Hi Mike,

Run this code:prenavigator.notification.alert(
'You are the winner!', // message
alertDismissed, // callback
'Game Over', // title
'Done' // buttonName
);/pre

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

Alert Handlers

Katya,

Yes but how do I fire this code only when the local storage variable (offline) is true?

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

Alert Handlers

Also, this code does not work for me when testing IPA on iOS 6 and 7. Alert never shows and the activity spinner eternally spins.

Return to “Issues”