Application Cache on Android using build.phonegap.com

  • 1
  • Problem
  • Updated 7 years ago
We want to wrap our GWT application using build.phonegap.com. The application uses Application Cache (HTML5 feature - the one that's let you use manifest file to list all resources of your web app that should be available offline).

We were using this feature about a year ago, when we did not know about phonegap. We were simply builing an Android app from scratched. The app was working fine.

Now we want to switch to PhoneGap. Application Cache does not work out of the box. Investigating the problem a little bit, it turned out that we've forgotten that in native Android App we needed to turn on these:

super.appView.getSettings().setDomStorageEnabled(true);
super.appView.getSettings().setAppCacheMaxSize(1024*1024*8);
super.appView.getSettings().setAppCachePath("/data/data/com.yourdomain/cache");
super.appView.getSettings().setAllowFileAccess(true);
super.appView.getSettings().setAppCacheEnabled(true);
super.appView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);

as described in this article:

http://tmkmobile.wordpress.com/2012/0...

Is there a way to enable those in PhoneGap?
Photo of Dominik Zalewski

Dominik Zalewski

  • 2 Posts
  • 0 Reply Likes

Posted 7 years ago

  • 1
Photo of Glenn Sheasby

Glenn Sheasby

  • 2 Posts
  • 0 Reply Likes
So, since we posted about this problem, PhoneGap 2.5 was announced with full appcache support by default. However, build.phonegap.com only uses PhoneGap 2.3. Is it planned in the (near) future for build.phonegap.com to upgrage to using PhoneGap 2.5?

Will our application work out-of-box if we build our app manually using PG 2.5, rather than using the build server?

Another problem we have is related to AJAX calls - the first thing we do on application load is get some data from our server (located on an http domain), but these calls fail with the error "Unsafe JavaScript attempt to access frame... Domains, protocols and ports must match." We thought that adding tags in the config.xml file would fix this problem, but the issue persists.

The config.xml file is actually being read (we get the app icons from the tags), but the tags don't seem to help us. Are they only for enabling hyperlink clicking, or will they also enable data access from external servers using AJAX?
Photo of Yi Ming Kuan

Yi Ming Kuan

  • 1840 Posts
  • 78 Reply Likes
PhoneGap Build will eventually add support for 2.5.0. Just keep watch on https://build.phonegap.com/blog - we'll announce there when it's ready on Build.

The AJAX issue is a security measure in Webkit. Are you using iframes?

-yiming
Photo of Dominik Zalewski

Dominik Zalewski

  • 2 Posts
  • 0 Reply Likes
Re: 2.5.0. Are we talking about weeks, months or years?

Re: Ajax. Yes, we are using iframes. We are actually using GWT and that's the way GWT implemented it. Can you advise?
Photo of Dominique Legault

Dominique Legault

  • 1 Post
  • 0 Reply Likes
I had a similar issue I had to make sure I set the

<access>*</access>
setting in config.xml

I'm now wondering if my application is caching rest responses from my server, I'll have a look at the html header I send and make sure that it's sending the correct expire tags.
Photo of Maryum Babar

Maryum Babar

  • 4 Posts
  • 1 Reply Like
Does Application Cache work on iOS(iOS 4.0 and later) using phonegap build ??