PhoneGap store HTML Files on Device - html

I have to build an App for Windows Mobile and iOS. So I decided to create this with PhoneGap.
The app should only display HTML-Files.
These files are stored on a server and can change every day.
So I created already an API which delivers the files.
My solution would be:
In my PhoneGap-App I use AJAX to get the files (this is no problem and should already work...).
To the question:
How can I store the files on the device? Is this possible with PhoneGap?
The app have to work offline too (because of this I need to store the files)...
And if this is possible: It should sync only the differences (between device/app and server) --> keyword rsync??
Thank you for your help!
Emanuel :)

Have you checked here?
You can definitely store files locally on android platform.(I have already done that). However, I haven't done it on IOS.
So please investigate, if features I gave the link above, available for safari (IOS).
Synching only diff should be implemented on the server side and should be responsibility of your API.

Yes you can store files locally.
I would recommend the Phonegap File Transfer plugin for downloading files. It supports iOS and Windows phone 7 and 8 and can download and save the file locally. At the Cordova file plugin github you can see the paths where you can save the files for iOS, I haven't found a table for windows phone yet.
But I would not recommend you download the HTML files since they can be very big. You should dynamically create the mobile pages you need, since you would only need to download the displayed text and attributes for some HTML-tags.
The way you can do this is by having a server back-end where you can change the content of the pages. The plain HTML should then be saved in a database with a creation and modification timestamp(needed to check if you have the latest updates). You would then pull the data out of the database with your PHP and echo it as a JSON. Your app just has to make a AJAX-GET request to the server and save the data locally in a database. I would recommend the Cordova SQLite Storage plugin for the local database. Whenever a page is opened you should dynamically create a mobile page.
This way your app doesn't request huge amount of data from a server, which can be more appealing to your app users.

Related

Ionic 5: How to write to local JSON files?

I'm developing an Ionic-Angular mobile application that involves tracking user progress. While I'm familiar with how to read from locally defined JSON files (and render that data), I've been unable to find any solutions online to write/append to local JSON files.
Until I'm able to utilize something like Google Firebase, I'd like to be able to just store this data by writing to local JSON.
Is there any way I can do this or is a database the only solution?
I'm assuming this is a web application. There is no way you can access the file system of the user to persist the data.
Other options
Index DB (save the information locally to the user at the browser level). User can go to the mobile device settings and clear it if required.
Use a mock api if this is only during the local development purpose (Use json-server and watch the database json file. You can update the database json file and it will reflect)
If you are building a hybrid application using ionic, then use one of the cordova plugins available here.
Use an actual backend service which persists it in the database.

Windows Phone 8.1 localStorage issue

I'm interesting if someone have experience loading local html file in windows Phone 8.1 WebBrowser control? It looks like WP treat local files as they don't belong to the same server, so it creates localStorage object for each file separately.
So if you create two WebBrowser controls in your app and load two html files in each of them, they don't see each other data. But if you close app and load it again, each remembered it's own data.
I know that WP 7.1 do not have localStorage, but WP 8.1 do, and I'm wondering why this not work like in Android or iOS.
Do you know any workaround?
I faced the same issue and it turned out that localStorage is stored separately when navigating via a different protocol. I solved this by referring to HTML source with 'x-wmapp0:' as prefix. This requires you to provide an absolute URI.
new System.Uri("x-wmapp0:/www/index.html", UriKind.Absolute);

Abobe Air/Flex 4.6 Remote File Viewer

I have a Air/Flex desktop application and I'm trying to create a component within the app that can view files on the web server is is already connected to. It just needs to access one particular folder that will contain PDFs, Images & Word documents. I also want the ability to click on the files and having them open in their default desktop applications.
Is this possible and how would I go about doing this?
It's possible but not with your Flex/AIR app alone. It cannot view files/directories on server by itself but it can communicate with your server via webservices, AMF, or any other back end based service. Typically the back end reads the folder and send this information to your app. Your app can open those files in corresponding app but only if those files are available on disk so your app will have to download them prior to opening them.
Every Application has different needs but I myself usually save anything to a desktop or you can use the App storage container as well. As I use only the desktop I download what is needed OR been asked for, and the visitor has the choice of keeping it or if not needed it gets automatically deleted! this way you can use whatever PDFs, Word, Images etc. use read and write (re-write) as well as creating PDFs on the fly with Images, text etc, and that way a visitor also can print directly at his or her own leisure. regards aktell

how to download audio file from from uri and save in local folder in windows phone 8?

I've got various types of ringtone in my server. I need to know how to read those audio files and save into my Windows Phone 8 directory.
How large are the files? The BackgroundTransferRequest API is one way you could download files. It is especially useful for larger files. Since this class downloads in the background it is nice in that you can navigate around your app and even leave it without having to cancel your download.
It also has some built-in functionality that will help limit downloads when you are on wireless vs wifi so your app won't accidentally eat up your user's data plan.
Here's some info on Background file transfers:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202955%28v=vs.105%29.aspx
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202959%28v=vs.105%29.aspx
An alternative is using an Http request using either the HttpWebRequest or WebClient classes. These options are good when you have smaller files and when you know you have a stable network connection. They will also work with larger files but they don't have the extra features that BackgroundTransfer API has for longer running downloads.
http://developer.nokia.com/community/wiki/Making_a_HTTP_request_and_listening_its_completion_in_Windows_Phone

Distribute html app on pendrive

I have an html app, with html, js, css and images, which I need to distribute on a pendrive for Mac and PC. When users open the app, however, they're receiving security errors in their browser.
I'm looking for a simple solution to this, but I can't find any easy way of opening a html app from a pen drive. Any solutions would be greatly appreciated.
EDIT:
You are right The error come from ajax local call to xml files.
Anyone has a solution ?
In reference to question - How can I make local ajax calls to xml files when distributing my html project locally?
The users who are having problems is probably due to the browser they are using and the state the browser was initialised in, as some browsers by default allow local ajax calls to files and some don't.
You have two options.
To your users specify a browser to run it in (for example chrome automatically disallows local ajax calls however if started with the flag --allow-file-access-from-files it will allow this behaviour)
Host the files on a web-server either in the flash drive or externally.
I think I have the solution.
With the mongoose portbla web server, I can launch a small web server without installation on mac an pc.
I just have to find how to put my page as default.
I wish it will help someone with the same problem.