Lucas
Lucas

Reputation: 384

Cache web forms with iOS

I'm building an online/offline application with Swift 3, PHP and MySQL (those are the technologies I know).

There are two applications, one application is iOS native, and uses a WEB View to load the form dynamically provided by a second web application that generates, with PHP, forms (admins can generate those forms). The web application provides a page with the generated form.

The person responsible to fill the maintenance forms can have access or not during his shift to wifi/internet (depending on their location). So that person will need to load all the forms before leaving the office and start their shift.

My question is how can I pre-load all those web forms, and then make them available as request without an internet connection?

The operators need to load all the forms online, fill them online/offline, and once they arrive to the office submit all those forms with the collected data during their shift.

The big problem for me here is that I couldn't find a way to store the forms on the iPad.

I read about doing it with the cache manifiest or using local storage over the web view, although doing that doesn't store the forms, just the data entered in the form.

Any idea, or suggestion will be greatly appreciated! Thanks.

Flow:

Web app -(create)-> New form <-(request)- web view (iOS)
                       ^
         MySQL (data)--|

Upvotes: 0

Views: 60

Answers (1)

carlos21
carlos21

Reputation: 485

I had to do exactly the same for a project. What I did is:

  1. Within the app the user downloaded this files in a zip after the first login, then this was uncompressed and stored in the Documents folder.

  2. When the user was offline, he was able to fill this forms (I needed to use a UIWebView to show html).

  3. User was able to save that data. (you can create a javascript function to serialize all form data into a json string)
  4. You can catch this json string by calling that javascript function with

    [yourWebView stringByEvaluatingJavaScriptFromString:@"yourFunction"];

  5. Having the json you can save it using NSUserDefaults, CoreData or SQLite

  6. When user is online, you can provide the ability to upload these json strings
  7. That's it!

Upvotes: 1

Related Questions