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
Trusted Contributor
Posts: 166
Registered: ‎12-09-2011
My Device: 9550,9300,9800,9700,9900,9850,9860

Sample Application Working for Both Online and Offline Mode

Hi,
Is there any Sample Application of BB10 Webworks Smartphone,
Which will run in both Online Mode And Offline Mode.

Actually I am working On a project which is working fine in Online Mode but When I Turn it in to Offline Mode its giving me Blank Screen evenif I am getting all the data from localStorage and Database.

Please help me if any one have any solution or having any code for this. 

Thanks & Regards,
Nitish Subudhi

Feel Free To Press The Like Button On The Right Side To Thank The User That Helped You.
Please Mark Posts As Solved If You Found a Solution.
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Sample Application Working for Both Online and Offline Mode

Where is your content (HTML, CSS, JS), packaged within the app or you redirecting directly to an URL in your config.xml?


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Trusted Contributor
Posts: 166
Registered: ‎12-09-2011
My Device: 9550,9300,9800,9700,9900,9850,9860

Re: Sample Application Working for Both Online and Offline Mode

Hi LBP,
All my content are packaged within the app.
And i am redirecting index.html in config.xml. 

Thanks & Regards,
Nitish Subudhi

Feel Free To Press The Like Button On The Right Side To Thank The User That Helped You.
Please Mark Posts As Solved If You Found a Solution.
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Sample Application Working for Both Online and Offline Mode

So all you need is to check if device is online, if this fails you can use the latest dataset from your localstorage or database, isn't it?

 

Can you share a little bit of your source code to see if there might be the issue when your localstorage/database isn't empty but your screen might stay blank?


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Trusted Contributor
Posts: 166
Registered: ‎12-09-2011
My Device: 9550,9300,9800,9700,9900,9850,9860

Re: Sample Application Working for Both Online and Offline Mode

Hi LBP,
here is my code:

if(!navigator.onLine) {
				alert("offline");
				changePage("gallery.html", "slide");
			} else{
				doBackgroundRequest();
			}

 and here I am using JQuery for page transaction.

I have check the database and localStorage by putting alert. And its showing the correct value and not showing any error message.
In Online it's working properly.
But in Offline I am getting Blank Black Screen. 

 

Thanks & Regards,
Nitish Subudhi

Feel Free To Press The Like Button On The Right Side To Thank The User That Helped You.
Please Mark Posts As Solved If You Found a Solution.
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Sample Application Working for Both Online and Offline Mode

Is your device connected to the Computer? If so remove the cable and try again. As far as I know the navigator.onLine might not be supported in every case on every device/OS, so I would also try to use the blackberry.system.hasDataCoverage to be checked.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Trusted Contributor
Posts: 166
Registered: ‎12-09-2011
My Device: 9550,9300,9800,9700,9900,9850,9860

Re: Sample Application Working for Both Online and Offline Mode

Thanks LBP,
I am checking the APS in simulator not in device.
If navigator.onLine is not supported in every cases then I will use  blackberry.system.hasDataCoverage and post here if it will work or not..  

Thanks & Regards,
Nitish Subudhi

Feel Free To Press The Like Button On The Right Side To Thank The User That Helped You.
Please Mark Posts As Solved If You Found a Solution.
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Sample Application Working for Both Online and Offline Mode

I may be wrong but I think somewhere I read that the simulator simulates to be always online.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Trusted Contributor
Posts: 166
Registered: ‎12-09-2011
My Device: 9550,9300,9800,9700,9900,9850,9860

Re: Sample Application Working for Both Online and Offline Mode

Actually I am "Turning OFF All Connection".
And checking in Offline Mode.

Thanks & Regards,
Nitish Subudhi

Feel Free To Press The Like Button On The Right Side To Thank The User That Helped You.
Please Mark Posts As Solved If You Found a Solution.
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Sample Application Working for Both Online and Offline Mode

I do not know where I read about it and couldn't find the link if I bookmarked it. For the device the PlayBook also worked that way if you are using the "blackberry.system.hasDataCoverage()" will always be true until the device is disconnected from the computer. This means also if you shut down the WLAN of a device connected to a computer will be throwing true from "blackberry.system.hasDataCoverage()".


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.