Cordova / Ionic database(Web SQL) disappears rando

2019-09-11 00:46发布

问题:

A Cordova/Ionic app I've built is having a little trouble. The problem is only appearing on one user's phone (out of about 6 different phones)

Essentially when randomly using the app, sometimes the user will return to the app to find the database / state is completely blank. I have a function that they can trigger to send me the entire db, and it's as if it just randomly resets itself. There is a single call to reset the database, but it is behind a yes/no prompt so I don't think it's user error.

The problem has pretty started last week, where the provisioning profile of the app (we are using enterprise deployment for sharing the app with the testing team).

Is there any chance that that switch of profile could have left the phone is a slightly odd situation where the database could become unstable?

回答1:

The answer was insanely dumb.

The db of a websql database (and I presume local storage potentially as well) is stored in the library/caches directory, which is not garenteed to be persistent. I had read in a number of places that said it was safe to use.

It took me 2 hours to switch out to using the native db (via a localforage adapter).

Pouch db also knows how to use a real database.

Don't go down this route.