Getting started developing an offline capable mobile app for Safari

It’s been a while since I’ve blogged here, mostly because I’ve been crazy busy. I’m working on several different applications at work, along with projects related to Cincinnatus Press, and writing books, and five kids, and … you get the idea.

But I’m learning some new technologies (new to me) on new apps, and I thought it was time I blogged about it.  I want to talk a little about a particular application I’m working on. The company I’m working for has about ten plants, mostly on the eastern seaboard, which deliver products to customers on a daily basis. Customers being other companies.  With every shipment that goes out, we send along paper delivery receipts which are signed, marked up, modified, then sent back on paper.  They’re scanned, then loaded into our systems, where they’re sent to accounting for billing purposes.

My task is to take that paper process and turn it into a paperless mobile app.


  • Application should be able to work fully offline for significant periods of time. Our drivers will need to be able to load up their iPads and walk away, with the applications syncing back on a as needed basis when connected, but storing data offline when there is no data connection.
  • Therefore: all pages need to be cached
  • I need to be able to locally store changes to the delivery receipts as well as signatures
  • I need to be able to periodically test for connectivity and upload changes back to the server
  • Optionally, I need to be able to detect geolocation at all times and upload that whenever I’m connected (currently each of our trucks carries a GPS, which contacts a paid service, which reports back to our applications.  If we can make the mobile devices do that reporting, then it will save us money, and therefore justify my salary.


I’ve only worked with a few mobile apps, however, and none which had an offline requirement.  So the first step is to review which offline technologies are available. Here is what I looked at:


  • This really would have been ideal for my purposes. Uses standard language, relational database, etc. Unfortunately…
  • It fell victim to a standards debate: Microsoft and Mozilla opposed Web SQL in favor of IndexedDB. So even though it will work in Safari, which did a full implementation of Web SQL, I probably shouldn’t use it because support could be dropped tomorrow. I need the application to be stable enough that I don’t have to revisit it next week.


  • No point in really discussing. Storage limits are too small for my purposes.


  • Not supported in earlier versions of Mobile Safari — not a deal killer, because we’ve standardized on Apple products and we can control exactly what versions the iPads will run. That’s the nice news about running a closed ecosystem.
  • It IS supported on Safari after version 8.  However, bugs have been reported, specifically this one: //
  • I need to find out if that is still the case, because that was when iOS 8 was first released. If that particular bug is still a problem, I may use IndexedDB -anyway- because I can figure out a workaround if necessary.

HTML5 Web Storage

  • Disavantage: not structured, no SQL data. String data only. I’m going to have to do some workarounds in order to store my data in any kind of a structured way.
  • Advantages: solid, persistent local store lasts between website visits. Easy to use, name value pairs. Data is stored on client only, it’s only sent back if I do it in javascript. Can store from 2 MB to 10Mb of data, depending on browser (in our case, 5Mb since we’re using Safari).
  • Because of the offline storage limits I’m going to need to be very conscious of how I store my data, especially the signatures.

Also have to deal with the available size of the offline application cache.  A quick google search tells me I’ve only got 5 Mb there, which is where I’ll need to store offline js, css, images, html, etc.  I don’t really know how big those are at this point, but when you start including images you can quickly get far beyond a 5 Mb limit.

In practice, I used the tester at this page to determine how much offline cache I can store on my ipad. //   I’m using a 3rd generation ipad (16Gb), which is older than the drivers will have.  The test returned the surprising result that I have an unlimited amount of storage available on the iPad.  I’ll start developing the offline piece based on my results here in the morning, and then we will see.

Leave a Reply

Your email address will not be published. Required fields are marked *