Page 4 of 5

Alert Handlers

Posted: Mon Jun 16, 2014 12:12 pm
by Mike6580064

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.


Alert Handlers

Posted: Tue Jun 17, 2014 12:44 pm
by Maryna Brodina

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.


Alert Handlers

Posted: Tue Jun 17, 2014 1:01 pm
by Mike6580064

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.


Alert Handlers

Posted: Tue Jun 17, 2014 3:08 pm
by Maryna Brodina

Got it! I'll update!


Alert Handlers

Posted: Thu Jun 19, 2014 5:41 pm
by Kateryna Grynko

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.


Alert Handlers

Posted: Mon Jun 23, 2014 2:11 pm
by Mike6580064

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...


Alert Handlers

Posted: Mon Jun 23, 2014 6:37 pm
by Alena Prykhodko

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


Alert Handlers

Posted: Mon Jun 23, 2014 6:48 pm
by Mike6580064

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?


Alert Handlers

Posted: Mon Jun 23, 2014 7:52 pm
by Mike6580064

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


Alert Handlers

Posted: Mon Jun 23, 2014 8:05 pm
by Evgene Karachevtsev

Mike,

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