Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Contributor
myok12
Posts: 8
Registered: ‎07-21-2011
My Device: Playbook

Bug report: navigator.onLine incorrect status

When using HTML5's Offline Web Applications (with a manifest file) and launching a pre-cached application, if the browser is being launched with no reception (or with airplane mode enabled), it will have HTML5's navigator.onLine === true. The value is updated correctly once you go in and out of reception again (or simply by disabling and re-enabling airplane mode).

If there's reception when the browser is first launched, the flag is working as it should.

 

This is a major issue since it only allows Offline Web Applications to rely on network timeouts for decision making, which harm UX.

 

I am using BlackBerry Playbook 1.0.6.2390.

 

Thanks,

Ohad Kravchick,

Thomson Reuters.

Retired
jeffheifetz
Posts: 518
Registered: ‎07-18-2011
My Device: Bold

Re: Bug report: navigator.onLine incorrect status

Hi myok12,

 

Thanks for the bug, I don't even think this API is properly documented in the Webworks docs, so I posted this issue.

 

As a workaround you can simply use the webworks api System.hasDataCoverage

 

<script type="text/javascript">
// See if we are in coverage 
	if (!blackberry.system.hasDataCoverage()) {
		alert("You are not in coverage, we will attempt to send later");
	}
</script>

 



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
New Contributor
myok12
Posts: 8
Registered: ‎07-21-2011
My Device: Playbook

Re: Bug report: navigator.onLine incorrect status

Saw this snippet already. Will give it a go Monday morning.

 

However, navigator.onLine is HTML5's standard way of implementing connectivity validation. And it works on the PlayBook, except in the provided scenario.

 

Our HTML5 app is expected to run within a regular browser. Is blackberry.system.hasDataCoverage automatically exposed in the browser, or is it only for bundled apps?

Retired
jeffheifetz
Posts: 518
Registered: ‎07-18-2011
My Device: Bold

Re: Bug report: navigator.onLine incorrect status

Sorry, the API is a WebWorks API, so you would need to make a bundled webWorks app to take advatage of the API.



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
New Contributor
myok12
Posts: 8
Registered: ‎07-21-2011
My Device: Playbook

Re: Bug report: navigator.onLine incorrect status

Ok, so that's a browser-related question. Should I ask this question on a different forum?

 

Retired
jeffheifetz
Posts: 518
Registered: ‎07-18-2011
My Device: Bold

Re: Bug report: navigator.onLine incorrect status

No, this is the right forum I just didn't know you were running a mobile site. 



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
New Contributor
myok12
Posts: 8
Registered: ‎07-21-2011
My Device: Playbook

Re: Bug report: navigator.onLine incorrect status

Ok, so just to clarify:

 

We have an HTML5 web app that suppose to run when online or offline -- for that we use a manifest file. This works correctly. 

On a different note, our app retreives data from our web services and videos from our video service, and caches it.

When the device is online, we decide, based on the data's age, whether we re-download it again or not.

When the device is offline (to supposedly be determine by navigator.onLine), we always recourse to cached data. If we instead try to initiate network retreival when offline, it tries and times out (after 20s).

 

From what I see, the PlayBook reports navigator.onLine correctly, except for when the browser launches without connectivity, and then until the connectivity status changes. However, this means that our (and others) webapps will assume network is connected at that time, and will try to contact servers.

 

Retired
jeffheifetz
Posts: 518
Registered: ‎07-18-2011
My Device: Bold

Re: Bug report: navigator.onLine incorrect status

I believe in this case you will recieve an appcache error event. As a workaround could you intercept the event and if so wait for the onLine to change before trusting the value?



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
New Contributor
myok12
Posts: 8
Registered: ‎07-21-2011
My Device: Playbook

Re: Bug report: navigator.onLine incorrect status

Thinking it over, the solution is quite good, as it will give us another way to tell if the user is offline in the begginning, but it still has a problem.

 

Assuming we are considering the user to be offline if we get applicationCache error, even though navigator.onLine===true, when the app laucnhes. How would we know if and when the user reconnects? applicationCache error state is the last state applicationCache will ever be in, so we can't deduce from it. And navigator.onLine will remain true if the user actually connects. We would just couldn't tell that the user has re-connected.

Retired
jeffheifetz
Posts: 518
Registered: ‎07-18-2011
My Device: Bold

Re: Bug report: navigator.onLine incorrect status

I guess the only solution is a timer that does an XHR request until the request finally succeeds and then you can trust the property



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)