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

Alert Handlers

Alena,

It's shared with you guys. "SID Digest..." is the name.

The steps listed in my above post were performed on both an iPhone 5 (v6) and an iPad Air (v7) after installing the IPA.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Alert Handlers

Hello!

I have just tested your app on iPad (iOS 7.1) and it seems to be working as expected.

When there is connection - "Incorrect user name and/or password" alert appears
When there is no connection - "Your device has no connectivity" alert appears

Please note, you have edited Source files in iOS folder. To test your app I had to download project backup, restore it and delete edited files (because my bundle id was not applied).

So please try to delete edited files on Source tab and undo all source changes.

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

Alert Handlers

Maryna,

Did you test it with the steps I provided?

If I disable my connection THEN run the app, I correctly get the "no connection" alert when I attempt to login.

If I CLOSE the app, THEN re-enable the connection, and THEN run the app again, I still get the "no connection" alert upon a login attempt and am unable to login at all--regardless of entering the correct credentials or not.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Alert Handlers

Got it! I'll update!

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

Alert Handlers

Hi Mike,

The issue is in your app logic. Online event doesn't fire when you run app (if online), it fires only if app is running in background. That is why when you follow these steps Online event doesn't fire and a localStorae variable isn't cleared.

Let's try checking connection.type on Device ready event:
http://docs.phonegap.com/en/3.3.0/cor...
Then clear your localStorage variable "offline" if there is an Internet connection when you run the app.

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

Alert Handlers

Thanks Katya. I've added the following on Device Ready:

function checkConnection() {
var networkState = navigator.connection.type;

Code: Select all

 var states = {}; 
 states[Connection.UNKNOWN]  = 'Unknown connection'; 
 states[Connection.ETHERNET] = 'Ethernet connection'; 
 states[Connection.WIFI]     = 'WiFi connection'; 
 states[Connection.CELL_2G]  = 'Cell 2G connection'; 
 states[Connection.CELL_3G]  = 'Cell 3G connection'; 
 states[Connection.CELL_4G]  = 'Cell 4G connection'; 
 states[Connection.CELL]     = 'Cell generic connection'; 
 states[Connection.NONE]     = 'No network connection'; 

}

But I'm not clear on exactly how to have it clear the "offline" variable if it detects a connection...

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

Alert Handlers

Hi Mike,

On device ready event add this code:

pre
if (navigator.connection.type !== Connection.NONE) {
localStorage.removeItem("offline");
} else {
localStorage.setItem("offline", "true");
}
/pre

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

Alert Handlers

Alena,

Am I adding this by itself or in addition to the function checkConnection?

Also, I need to clear the "offline" variable if the device HAS a connection. Won't your code clear it if there's no connection?

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

Alert Handlers

I've added the following on Device Ready and it works now:

if (navigator.connection.type !== Connection.UNKNOWN) {
localStorage.removeItem("offline");
}
if (navigator.connection.type !== Connection.ETHERNET) {
localStorage.removeItem("offline");
}
if (navigator.connection.type !== Connection.WIFI) {
localStorage.removeItem("offline");
}
if (navigator.connection.type !== Connection.CELL_2G) {
localStorage.removeItem("offline");
}
if (navigator.connection.type !== Connection.CELL_3G) {
localStorage.removeItem("offline");
}
if (navigator.connection.type !== Connection.CELL_4G) {
localStorage.removeItem("offline");
}
if (navigator.connection.type !== Connection.CELL) {
localStorage.removeItem("offline");
}

Thanks

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

Alert Handlers

Mike,

Thank you for the update. Do not hesitate to contact us if you need any further help.

Return to “Issues”