Adam Garbinski
Posts: 0
Joined: Sat Sep 28, 2013 5:33 pm

iPhone 5s and online/offline event

Hello,
I have the following issue regarding iOS 7.0.4 and iPhone 5s:
When I try to simulate 'online' and 'offline' event by switching the phone to 'Flight mode' it triggers at leas two consecutive events instead just one. So first I got 'offline' event detected and then after 1 second I get 'online' event detected, even if there is a clear evidence that the phone is in 'Flight mode' (airplane icon, and all communication ports shut down). The same issue occurs when I turn off 'Flight mode', so I get at least two events detected instead one.
From my tests it appears that the sequence is as follows:

Turn on 'Flight mode' (phone offline)
1) offline event triggered
2) online event triggered

Turn off 'Flight mode' (phone online):
1) offline event triggered
2) online event triggered
3) offline event triggered

This issue is not present on iPhone 4s.
Do you know a simple solution to remedy this problem? I have local storage variable dependent on that events so app logic is broken down by this issue.

Adam Garbinski
Posts: 0
Joined: Sat Sep 28, 2013 5:33 pm

iPhone 5s and online/offline event

Well, I was able to fix it on my own by adding this JS to 'onLine' event in Appery builder:

var currenttime = new Date();
var lasteventtime = new Date(parseInt(localStorage.getItem('onLineTime')));
var timespan = (currenttime.getTime() - lasteventtime);
if (timespan = 5000 || isNaN(timespan)){
if (localStorage.OnLine == 'false'){
localStorage.setItem('OnLine', 'true');
localStorage.setItem('onLineTime', currenttime.getTime());
}
}

and this JS to 'offLine' event:

var currenttime = new Date();
var lasteventtime = new Date(parseInt(localStorage.getItem('onLineTime')));
var timespan = (currenttime.getTime() - lasteventtime);
if (timespan = 5000 || isNaN(timespan)){
if (localStorage.OnLine == 'false'){
localStorage.setItem('OnLine', 'true');
localStorage.setItem('onLineTime', currenttime.getTime());
}
}

I wonder if there is any other solution.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

iPhone 5s and online/offline event

Hi Adam,

Thank you for the update.

We'll look if there is an another solution, but need to test it on the iPhone 5S, so it might take some time.

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

iPhone 5s and online/offline event

Hello! It's not reproducible on iPhone 5/ iOS7. Unfortunately we don't have opportunity to test on iPhone 5s.

Return to “Issues”