PhoneGap for offline access

73 views
Skip to first unread message

Blackwind

unread,
Aug 16, 2008, 1:12:30 AM8/16/08
to phonegap
I love to the ability to throw in some javascript and basic html and
have my webapp run completely offline, the code executed through the
PhoneGap application. Is that even possible?

kazoomer

unread,
Aug 16, 2008, 2:09:07 AM8/16/08
to phonegap
I believe it is possible and we are looking into a few different
approaches.

I put together a prototype where html is compiled and rendered into
the app at startup. There are problems, JavaScript does not run
(currently) and resources are not really linked together as they are
all bundled/compiled in.

The next idea (and best case) would be to have the app request an "off-
line" app that is downloaded on first run from a server. These files
are cached and saved on the client (iPhone) and always run before any
on-line files run. We would have to come up with a special file schema
for linking resources but I believe it could work. Im still
researching what and where we can save to on the iPhone OS and since
I'm new to Objective C so it is going slower then I would like.

The nice thing about the above approach is we could have the client
side app re-request the code with some call back, so if the app
changes, but the off line and on-line parts could be upgraded at any
point.

Ive even looked into embeding a full webserver and serving files with
PHP or Ruby, but I think that is overkill for what we really want to
do. (HTML/JavaScript)

Anyway, feel free to add your two cents.

Rob Ellis

Dirk Holtwick

unread,
Aug 16, 2008, 4:47:44 AM8/16/08
to phon...@googlegroups.com
kazoomer schrieb:

> The next idea (and best case) would be to have the app request an "off-
> line" app that is downloaded on first run from a server. These files
> are cached and saved on the client (iPhone) and always run before any
> on-line files run. We would have to come up with a special file schema
> for linking resources but I believe it could work. Im still
> researching what and where we can save to on the iPhone OS and since
> I'm new to Objective C so it is going slower then I would like.

I think the "load to offline" is the best approach. Maybe the app could
start with ZIP file in the bundle which is deflated on the first start
of the app, so you get both: direct offline support and the possibility
to update.

BTW: The code on the http://github.com/sintaxi/gap/tree/master page
didn't change since 3 days. Isn't there new code?

Nice weekend
Dirk

Peter Ferne

unread,
Aug 16, 2008, 6:41:02 AM8/16/08
to phon...@googlegroups.com

> Ive even looked into embeding a full webserver and serving files with
> PHP or Ruby, but I think that is overkill for what we really want to
> do. (HTML/JavaScript)

I don't think it would overkill at all, I think it would be the Right
Way To Do It. There are several mature, stable, opensource webservers
available ranging from apache (which runs on my N95) to Jetty,
designed as an embedded server, which could be ported or adapted. No
particular need for php, ruby etc. so a basic one could be very small
and lightweight. Great idea and probably simpler and cleaner than the
alternatives.
--
petef

voodooz

unread,
Aug 16, 2008, 11:50:57 AM8/16/08
to phonegap
It might be the right thing to do but you might have to jailbreak your
phone to make that work. I 'think' apple would frown on it but could
be wrong.It is really pretty kick ass you can do that on the phone
(run a web server) though fersure.

kazoomer

unread,
Aug 16, 2008, 12:26:59 PM8/16/08
to phonegap

> BTW: The code on thehttp://github.com/sintaxi/gap/tree/masterpage
> didn't change since 3 days. Isn't there new code?

Yes I have a separate Git Hub account, but the code is not stable, so
It has not been merged back into Sintaxi's repo. Brock (Sintaxi) has
gone on holidays for a week so I'm going to have to manage the fort.

We are still working on the project, but your right the updates are
not coming as fast as I or everyone would like.

Rob

Blackwind

unread,
Aug 16, 2008, 2:22:28 PM8/16/08
to phonegap
Great news. I'm glad you guys are on top of it. This is really one
of the last big deficiencies of javascript/webbased apps.
Once you are able to load webapps offline...it'll be a much more even
ground.

This is how I originally envisioned it, you load the app for the first
time, the content (css, js, images etc) are automatically cached into
an sql table. Once the items is in the sql table, it always loads it
from the table. Each app will have a small "Check for updates" button
which essentially clears the table and refreshes the page.

Though the server idea sounds great (in fact it'd just be down right
awesome), but unfortunately it most likely will not be allowed in the
app store.

Keep up the great work! I can't wait to check back for more news!

jpick

unread,
Aug 16, 2008, 3:48:09 PM8/16/08
to phonegap
On Aug 15, 10:12 pm, Blackwind <beck...@gmail.com> wrote:
Here's a link to how to store an entire webpage in an URL.

http://blog.clawpaws.net/post/2007/07/16/Storing-iPhone-apps-locally-with-data-URLs

I'm going to give it a try.

Cheers,

- Jim

jpick

unread,
Aug 16, 2008, 8:49:34 PM8/16/08
to phonegap
Okay, I tried encoding the pages into data URLs and it works.

http://github.com/jpick/gapoffline/tree/master

(I theoretically renamed enough things so that this can be built and
installed as a separate app in parallel with the mainline)

Some issues - I tried to encode the entire demo into the URL (eg.
images, mootools, etc.), and it weighed in at 200K just for the URL.
It worked OK in the simulator, but not on the device. It was too
slow.

So I removed the Bounce demo, which cut it down to 44k. That seems to
work OK. It even works in Airplane mode. :-)

Look at ./generate.sh to see a crude shell script for encoding the
pages into an URL.

Two days ago, the GPS and Vibrate demos, and the accelerometer were
working for me - they aren't working now. So it's not that great of a
demo -- at least the Flick demo works (but that doesn't really use
much of PG). Is it possible that the HTML at http://phonegap.com/demo/index.html
is out of sync with what's on Github?

Cheers,

- Jim

On Aug 16, 12:48 pm, jpick <jim.p...@gmail.com> wrote:
> On Aug 15, 10:12 pm, Blackwind <beck...@gmail.com> wrote:
>
> > I love to the ability to throw in some javascript and basic html and
> > have my webapp run completely offline, the code executed through the
> > PhoneGap application.  Is that even possible?
>
> Here's a link to how to store an entire webpage in an URL.
>
> http://blog.clawpaws.net/post/2007/07/16/Storing-iPhone-apps-locally-...

kazoomer

unread,
Aug 17, 2008, 1:29:27 AM8/17/08
to phonegap
Nice work Jim your killing it!

Ill talk a closer look at how you put it put it all together.

Im super excited to see this part of the framework working!

Rob

On Aug 16, 5:49 pm, jpick <jim.p...@gmail.com> wrote:
> Okay, I tried encoding the pages into data URLs and it works.
>
> http://github.com/jpick/gapoffline/tree/master
>
> (I theoretically renamed enough things so that this can be built and
> installed as a separate app in parallel with the mainline)
>
> Some issues - I tried to encode the entire demo into the URL (eg.
> images, mootools, etc.), and it weighed in at 200K just for the URL.
> It worked OK in the simulator, but not on the device.  It was too
> slow.
>
> So I removed the Bounce demo, which cut it down to 44k.  That seems to
> work OK.  It even works in Airplane mode.  :-)
>
> Look at ./generate.sh to see a crude shell script for encoding the
> pages into an URL.
>
> Two days ago, the GPS and Vibrate demos, and the accelerometer were
> working for me - they aren't working now.  So it's not that great of a
> demo -- at least the Flick demo works (but that doesn't really use
> much of PG).  Is it possible that the HTML athttp://phonegap.com/demo/index.html

Lieven Gekiere

unread,
Aug 17, 2008, 6:04:38 AM8/17/08
to phon...@googlegroups.com
Is there / will there be a way to detect that a user is not online (no
internet connection). I think we will need that to show an error or
message in case you have parts of your page that need online access to
a DB or so.

Liviooo

Blackwind

unread,
Aug 17, 2008, 10:37:00 PM8/17/08
to phonegap
This is getting really exciting! Keep up the great work!

On Aug 16, 5:49 pm, jpick <jim.p...@gmail.com> wrote:
> Okay, I tried encoding the pages into data URLs and it works.
>
> http://github.com/jpick/gapoffline/tree/master
>
> (I theoretically renamed enough things so that this can be built and
> installed as a separate app in parallel with the mainline)
>
> Some issues - I tried to encode the entire demo into the URL (eg.
> images, mootools, etc.), and it weighed in at 200K just for the URL.
> It worked OK in the simulator, but not on the device.  It was too
> slow.
>
> So I removed the Bounce demo, which cut it down to 44k.  That seems to
> work OK.  It even works in Airplane mode.  :-)
>
> Look at ./generate.sh to see a crude shell script for encoding the
> pages into an URL.
>
> Two days ago, the GPS and Vibrate demos, and the accelerometer were
> working for me - they aren't working now.  So it's not that great of a
> demo -- at least the Flick demo works (but that doesn't really use
> much of PG).  Is it possible that the HTML athttp://phonegap.com/demo/index.html

Ighal

unread,
Aug 18, 2008, 11:01:20 PM8/18/08
to phon...@googlegroups.com
I dont get it... I put my URL in the url.txt file and it still needs to be connected to the web to display the content... im trying with www.ighal.com

Am i doing something wrong?

Thanks!

kazoomer

unread,
Aug 19, 2008, 1:55:06 AM8/19/08
to phonegap
Nope thats right, I updated the JavaScript and didn't update the repo
to match, check out my repo at: http://github.com/silentrob/gap/tree/master
if you run into any other problems, let me know.

Rob

On Aug 18, 8:01 pm, Ighal <ighal...@gmail.com> wrote:
> I dont get it... I put my URL in the url.txt file and it still needs to be
> connected to the web to display the content... im trying withwww.ighal.com
> Am i doing something wrong?
>
> Thanks!
>

pvb

unread,
Aug 19, 2008, 6:50:30 AM8/19/08
to phonegap
Did you look at Jiggy? http://www.jiggyapp.com/
It allows for offline javascript apps on the iPhone, including native
UI. It delivers a very rich javascript implementation on the iPhone.
Its original developer abandoned the project, someone else
(www.saurik.com) is now apparently doing a port to iPhone OS 2.0.
Of course, due to Apple license restrictions chances are very small
Jiggy will ever be released through the AppStore.
Also see:
http://groups.google.com/group/jiggyapp-devel
http://code.google.com/p/jiggytype/
http://www.ipodtouchfans.com/forums/forumdisplay.php?f=115

Ighal

unread,
Aug 21, 2008, 12:14:58 PM8/21/08
to phon...@googlegroups.com
Kazoomer,
Im still running into some problems with the offline thing... 
Lets start again from scratch.
My objective is for the phonegap to basically "download" a simple webpage for offline view. So phonegap should download the web files once it is compiling so when the app is created all the html information is included into the application and there is no need for the iphone to be connected to the internet to use that app and view the content... is this something possible to do?

Thank you!

kazoomer

unread,
Aug 21, 2008, 12:47:08 PM8/21/08
to phonegap
Ighal

I believe this is possible and this is our goal. We still have some
major hurdles to get over before this is possible. I want to sync up
with Jim Pick and make sure we are on the same page.

Ill keep you posted.

Rob

On Aug 21, 9:14 am, Ighal <ighal...@gmail.com> wrote:
> Kazoomer,Im still running into some problems with the offline thing...
> Lets start again from scratch.
> My objective is for the phonegap to basically "download" a simple webpage
> for offline view. So phonegap should download the web files once it is
> compiling so when the app is created all the html information is
> included into the application and there is no need for the iphone to be
> connected to the internet to use that app and view the content... is this
> something possible to do?
>
> Thank you!
>

Chris Blown

unread,
Aug 22, 2008, 2:46:12 AM8/22/08
to phon...@googlegroups.com
Does the iPhone SDK have a native way to determine network availability - implementing a way for online / offline app modes would be cool.

Dirk Holtwick

unread,
Aug 22, 2008, 4:38:54 AM8/22/08
to phon...@googlegroups.com
Yes it has as far as I know. It is also possible to check which kind is
available: wifi, 3g, edge

Dirk

Chris Blown schrieb:

Lieven Gekiere

unread,
Aug 22, 2008, 4:43:08 AM8/22/08
to phon...@googlegroups.com
cool, this should be implemented in the javascript.


Lieven

Liviooo

unread,
Oct 3, 2008, 5:13:06 AM10/3/08
to phonegap
Dirk,

Could you share this network detection code so that we can implement
this in Phonegap or our website ?

Lieven

On Aug 22, 10:38 am, Dirk Holtwick <dirk.holtw...@gmail.com> wrote:
> Yes it has as far as I know. It is also possible to check which kind is
> available: wifi, 3g, edge
>
> Dirk
>
> Chris Blown schrieb:
>
> > Does the iPhone SDK have a native way to determine network availability
> > - implementing a way for online /offlineapp modes would be cool.

Dirk Holtwick

unread,
Oct 5, 2008, 10:28:33 AM10/5/08
to phon...@googlegroups.com
Hi,

I didn't yet implement such a feature. There is a sample in the SDK
showing how this one works. I forgot the name but it should be easy to
adopt it for PhoneGap.

Cheers
Dirk

Liviooo schrieb:


> Dirk,
>
> Could you share this network detection code so that we can implement
> this in Phonegap or our website ?
>
> Lieven
>
> On Aug 22, 10:38 am, Dirk Holtwick <dirk.holtw...@gmail.com> wrote:
>> Yes it has as far as I know. It is also possible to check which kind is
>> available: wifi, 3g, edge
>>
>> Dirk
>>
>> Chris Blown schrieb:

>>'t yet

Reply all
Reply to author
Forward
0 new messages