Google Drive Realtime API offline and sync support - javascript

I want to build a mobile web app with transparent offline and sync support for collaborative persistent data. I am considering using Google Drive Realtime API for the backend. How well is offline and sync supported by the API? Does it just work "automagically" from the included API scripts, or should I use some "plugin"? I have searched the documentation without luck.
What I mean by offline and sync support is that, when offline, it should be possible to
- edit the latest synced version of a document/object previously retrieved from the server
- create new documents/objects
- store all documents/objects locally
As soon as the app goes online again, all modifications and new docs/objects stored locally should be "merged" or "synced" with the server versions.

There is no explicit offline support. The API will deal well with flaky internet connections, but you can't load or create entirely offline.
I'm not sure what you mean by sync support, but if you have an internet connection it will automatically sync changes from collaborators and persist them on the server.

Related

Solution for identify mobile devices by mobile browser

I'm wondering it's possible to identify android device by web app running on mobile web browser? And this solution have to still working after change or upgrade web browser on this phone.
My second doubt is web app can working offline on phone showing PDF presentations saved in local storage (disk). When I have internet connection I can manually sync presentations (some are removed and some are downloaded).
If PWA app can work like I described above or in this case we need to use (hybrid) mobile app ?
PWAs allow to cache assets and make them available to the users even when they are offline. There are some functionalities that only Native Apps have (eg. access to a device contacts), but they are very close under many other aspects.
I wrote an article about Service Workers and caching strategies where I explain how to cache static assets as well as HTTP GET calls. It is part of a series about PWAs, so you might find it useful to get more insights about this technology.
Have a look at the website what web can do today to have a list of WEB APIs currently available:
I do not know the detail of your requirements, but maybe you do not even need to implement an hybrid app and simply create a PWA.

Are Service Workers necessary for a Progressive Web Application?

Service workers are not supported by all browsers; caniuse estimates that they would work for approximately 85% of users.
If i built a PWA, does it need to use service workers?
This will depend on the browser, but if you want your PWA to be installable, most browsers require that there is a service worker which has a fetch handler.
https://web.dev/install-criteria/#criteria
Referring to Chrome:
Registers a service worker with a fetch handler
It also says:
Other browsers have similar criteria for installation, though there may be minor differences.
In my experience service workers aren't mandatory to deliver a PWA with offline functionality.
As long as your PWA pages are properly marked as cacheable you can run your PWA completely offline and it won't need a connection to your server if the lifetime of the page is in the browsers cache lifetime.
The "Create Shortcut" functionality of Chrome is driven by the webmanifest and not by the fact that it uses a service worker. You can create a desktop shortcut for a page if it has a manifest.
You can furthermore do an AJAX call to a URL which is definitively not cached to figure out if you are running off-line or online and update your page if the 'update' URL tells you to do so by using location.reload()

Will my apps lose localStorage data if Crosswalk updates it's internal browser?

Recently I adopted cordova's crosswalk plugin to ensure a uniform and performant HTML5 environment across android devices. Everything was working fine until I deploy the application. That's when I noticed that all existing settings from the native browser, which was being used by the cordova webview were gone! Our localStorage was now in a different browser - the chromium browser which is served by crosswalk project.
Now I'm asking myself what will happen if the crosswalk project updates it's internal browser to a new chromium browser version? Will I lose the localStorage data once again?
Here are some references that I had look at while researching into the subject:
Crosswalk storage limits
Scope of sessionStorage and localStorage
Where the sessionStorage and localStorage stored?
Probably yes, you will lose the data. Also updating the device SO can cause the loss of data. I had the same problem. You should consider to use sqlite database to persist permanently your data.
The issue that was concerning this subject was closed last week. "Not able to migrate the existing webview data (localstorage/websql) to crosswalk"
Check it out here: https://crosswalk-project.org/jira/browse/XWALK-7368

Can an offline JavaScript app using service workers work after browser restart?

Application cache as a means of creating offline browser apps has been deprecated. The current way to make an offline web app is to use service workers.
Service workers allow you to bootstrap all network requests and provide content for them. Since service worker can run even when user closes the tab, it can provide cached content when internet temporarily doesn't work.
However when I got interested in offline web applications, it was because I hoped to use even when I have permanently no access to internet. I created simple offline app, but it does not work when I close and open the browser — I get message that page cannot be loaded.
Is there a way to make service worker offline app work even after browser is closed and re-opened? If not, are there any planned standards for this? It would be very valuable to mobile users.
Can an offline JavaScript app using service workers work after browser restart?
Yes, it can, provided it's cached all of its resource previously. This example goes through the steps of ensuring that.
The reason it can is that when you navigate to the URL that the service worker is registered for, the cached copy of the service worker is activated and it's given the opportunity to satisfy network requests for the app. So if you've cached everything, and you satisfy all of the requests by handling the fetch event, your app can be entirely offline.
There is a great deal of development in the area of service workers. Chrome is taking the lead, but Firefox follows closely. IE support is negligible however.
You can see the W3C working draft. For browser support, check e.g. here.
I also suggest taking a look at Nolan Lawson's pokedex.org application, it is an offline-capable web app based on service workers.

Using HTML5 to store a database offline and update changes when the connection is restored

I'm just in the design stage of a new project. I'm wondering what technologies one would use to implement a small Progress (or MySQL) database that would allow browsers (on an iPad/iPhone/android or laptop etc) to download the database after they sign into the web page, then they could edit it while online or offline.
If they're online, changes could be updated immediately, but if they're offline they can modify the data locally and as soon as the connection is restored it can upload the data to the server.
Is there a technology available in HTML5 that would allow this to occur?
Are there limits on file size for the data that can be stored locally?
I believe the database will be small, but it may grow in some areas. Because we only need to fetch the data for that specific user, it should be quite minimal. We really want to do this as a web app to ensure cross platform compatibility, perhaps jQuery Mobile or just HTML5 and JavaScript. We would prefer not to have to develop an iOS app, Windows Form program, android app, etc.

Categories

Resources