Is truly persistent storage possible in a progressive web app? - progressive-web-apps

I was reading this guide on offline storage for PWA's that described two storage API's, the Cache API and IndexedDB, however it seems that neither storage option is truly persistent. The Cache API is temporary by design, and the IndexedDB data can be wiped when the user clears their browser cache.
So, is it possible to have truly persistent storage in a PWA? What I'm trying to do is this:
User visits my website on their smartphone and I generate a unique ID in JavaScript.
They press "add to homescreen" on iOS or press the "add to homescreen" bar on Android.
The PWA gets added to their phone. At this point, I would like to store that unique ID persistently.
Is there any way that I can do so? Maybe an API that I don't know about? I only need a tiny unique code, since this PWA is not designed to have users log in with cookies.

No
The user can delete the PWA (if installed on Android) and clear their browser's cache of everything from your PWA.
Then if they visit again you would need to generate a new ID for them.
But you would know nothing of their previous ID if you have no login back end tied to unique users.

As Mathias already stated, it is not possible to achieve your goal with just PWA, as the user can wipe all the previously generated data.
So, long story short, you must use some other solution to ensure "truly persistence storage".
For example in a personal PWA Project of mine, I use Cloud Firestore. It offers also a very generous free tier you can use and it even allows offline persistence, granting full CRUD operations to your application (even when offline!).
Service Workers, through the Cache API, allow to cache only GET Requests, but no POST.
I wrote another answer about this on SO. And here you can find the official documentation.

Related

What is the easiest way to fetch data dynamically from a cloud storage to a flutter app

I am looking for a way to fetch data to my flutter app which can be adjusted and modified dynamically after deploying the app. As an example, if I want to change the images of the carousel depending on promotions or launch new books to the digital library. I need an economic option to host the data in cloud storage and fetch it from there.
I have considered firebase as well as google drive, but have yet to find a good guide. being a beginner and having concerns about security I want some expert advice if possible.
*edit-
Seeing many a tutorial I assume there is no better way than linking file URLs from the
Cloud Storage. So to dynamically change those is it possible to refer the URLs to some excel sheet fields to obtain URLs. Those fields can certainly be adjusted then without any hard coding. but the question is how to refer to such a sheet file? *
I also want to segregate the users into paid and free users, I have successfully proceeded with the authentication with firebase but still don't understand(I do have some concepts but don't know where to do that) how to put them in groups and impose limitations on them about accessing the data. any guidance, links and helpful advice will be cordially appreciated.
According to what you are looking for, I highly recommend you to use Firebase Remote Config, which is a cloud tool that allows you to modify your app's functionality and appearance without forcing users to download an update. You define in-app default values that control the functionality and appearance of your app when you use Remote Config. Then, for all app users or for subsets of your user base, you may utilize the Firebase console or the Remote Config backend APIs to modify in-app default values.
Your program can control when updates are applied, and it can check for updates regularly and apply them with minimal performance impact.
Remote Config comes with a client library that takes care of essential functions like fetching parameter values and caching them while still allowing you to manage when new values are active and how they affect the user experience in your app.
Here is a tutorial that uses Flutter and Firebase Remote Config that could also help you.

How to download a csv file from Google Drive to show the content in a mobile app

I am totally new in mobile app development and consequently very confused about how to get going (independent from how much I have read Google Drive API documentation over and over again.)
The way I would like to implement my (initially "android") mobile app (which I will develop by using ionic):
I will have a Google Drive account where I will have 1 CSV file. I will periodically renew the content of the file in the background (possibly twice a week).
The mobile app that I will develop will just retrieve the file from Google Drive, process the content and show it to the user in a more readable (easy to understand) format.
My app will not upload any data/file from the user device to the Google Drive. The app will only retrieve a file from Google Drive to show the content to the user.
Question 1) Does this approach make sense? I ideally would like to eliminate the work for back-end development. Or would you suggest another approach to do the same thing (with or without Google Drive)?
Question 2) The authorization process looks quite confusing to me as it is explained in Google's documentation. I could not find relevant information only addressing the scenario I have in my use case. Requirements: The mobile apps can fetch the corresponding file (or the content of it) and process it to show to the end user, but mobile apps (or any other client) may not update/edit/delete the file, cannot add a new file either. The only purpose of using the Google Drive will be to enable the mobile app fetching the data that will be shown to the user. How can this problem be solved by using Google's OAuth framework? A step by step action plan would really be appreciated.
ADDENDUM
You are also welcome to share your view if I should instead consider using Firebase for my problem, which I guess will be more costly.
Based on discussing the requirements with you, I would recommend against trying to do this with Google Drive API.
There are no tutorials out there for Ionic 4 + Google Drive API, and only a few for older versions. It will be an uphill struggle to create a solution that isn't going to scale well.
Instead you should start looking into using Firebase.
There are lots of tutorials which show you the basics: setting up a login system, and reading some data from the database.
The free limits are quite generous.
You can implement caching into your app so that you store a copy of the data on the device, and only refresh it either weekly, or more advanced, put a second table in that records the last updated date for the main table.
Firebase charges by reads so if you can set it up so that you only read one record (last updated) instead of downloading the whole database every time, then you can stretch your free tier a lot further.
If you do outgrow the free tier and the app is not generating enough to cover the costs then you have the option of investing time instead of money. There are guides in the docs about exporting the users and they provide tools so that the passwords can be put into another system without requiring the users to reset their passwords. The database can be similarly exported.

Web app roll out

I've been developing web apps some years now, actually as a hobby. When I write something, unsing Laravel, Sails.js, or Meteor and I add a feature, I upload it and it's there, for everyone.
However, I've always been wondering how bigger sites like facebook manage to roll out features to just some users. Do they push their changes to just some servers? But in that case - how do they manage the make the selected users access just these servers?
Or some db entry to see if the user has access to the feature/ version?
So how does it work?
Really interested in this :)
Large sites like Facebook use a technique called Feature toggles to control the functionality that is active at run-time. The following blog article describes Facebook's approach:
https://abhishek-tiwari.com/post/decoupling-deployment-and-release-feature-toggles

Packaged App: syncFileSystem / fileSystem API - For *large* files

I am looking to develop a Chrome Packaged App that will (at a very simple level) provide a dynamic form filling UI - but allow users to attach large attachments to the forms (could be upwards of 10 files of 10MB each). I would like to have the ability to save and share the form data and the attachment via Google Drive. The forms will be completed collaboratively by multiple team members who also need to all see the attachments. Imagine a form front-end/metadata that sits on top of a shared Google Drive folder...
I have read the documentation, and learnt that the syncFileSystem API is not intended for use for general and/or large files to be stored in Google Drive, but rather for small configuration data.
I then looked at the fileSytem API - hoping that I could include the Sandboxed folder for the app in the folders that the Google Drive Client App (so that the files get synced automatically) - but it doesn't look like the sandbox is meant to be accessed externally.
My current thinking is to recreate a windows explorer type UI in the packaged app (can use drag and drop) - then store the files in the sandbox using the fileSystem API. I can reuse the code from the Google Drive sample packaged app to implement cloud syncing. Good idea?
Two questions stem from this:
How persistent is the fileSystem API. The documentation mentions that the user can purge all stored files - is this done through 'clearing all browser history' ? In which case they could very easily accidentally wipe many hundreds of MB of useful information that I am storing in the packaged app.
I have read that you can use a 3rd party authentication services (which I want to do). If I use a non-Google account to authenticate my users, how would the Google Drive authentication work ? Would I be able to use a different Google account to perform the cloud storage (i.e. unrelated to the actual end user, who may or may not have a Google account already - which may already be signed in)
It seems like waiting for this https://code.google.com/p/chromium/issues/detail?id=148486 (getting read access to non-sandbox directories) would be the easiest way forward.
I don't think clearing browser history deletes temporary sandbox filesystem files, they're supposed to be sort of automatically garbage collected when space is required. It would make sense if that were another checkbox in the "Clear browsing data" section of chrome's options. Perhaps that would make the answer to your first question more clear :-)
The second point, I am not sure how to do this, but it looks like you have already figured out something? At least that's what this page https://groups.google.com/a/chromium.org/forum/#!topic/chromium-apps/hOYu75Cv0AE seems to indicate

iOS data sharing to Google Apps for social features: Workable?

I'm putting on my thinking cap for this one, looking for a high level overview of possibility. I'm the author of an iPhone app that tracks user generated statistics. Data is essentially stored in a table on the device, with each entry having several fields/columns. Users can then sort that data, view graphs, and do other nerdy number crunching stuff. I want to take it farther and incorporate a sharing platform online. Game Center, Open Feint and other third party platforms are too narrow in scope. I'm interested in writing a web app, that users can visit to do three things:
Post New Table entries (automated by device)
View own entries and share via web (read only)
View other members table entries (read only)
Is Google App Engine a viable solution for this? My iOS app will require a POST URL, and the web app will need to save that authenticated user's data, and possibly return an "identifier" value to be referenced in the future in case the user needs to modify the item on the web. It will also require a GET URL to retrieve the authenticated user's statistics one by one or in total.
Next, the user will be able to visit the website and type in a "username" (probably email address) and see read-only statistics that have been submitted.
Thank you in advance for your input.
Sure, you could do all that with App Engine. If you wanted to, you could even make that local table of data sync with your app on GAE.
Really, there's not much on GAE that you can't do, although sometimes the database layer take some time to get used to.
My personal preference would be to set up a Django instance, but you could use any Python or Java-based app, depending on what you're comfortable with.
In short, yeah, you won't have any trouble doing basic REST work with GAE, and you could probably push it harder to do some more number crunching on those stats.