apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.16k stars 989 forks source link

Opening Websql Database on IOS #1043

Closed Magu0013 closed 3 years ago

Magu0013 commented 3 years ago

I took over an Cordova cross platform app that still uses websql and need it to switch to the sqllite plugin. I had no problem doing this with android, but im stuck with the IOS version.

My main problem is, that I need to acces the Websql database one last time to copy the data to the new sqllite DB. On Android everything works, but no matter what I do on IOS, it says that websql ist deprecated. I know its deprecated but the customers still have data on the old Database, and the App in the store still uses websql. To move to a new standard I need to acces the Websql DB one last time to transfer the data.

Also the app thats aleready published in the store works without any problems, so websql still works ther.

What can I do to save the Data inside the old websql DB?

NiklasMerz commented 3 years ago

As far as I understand this is not a Cordova issue in particular. WebSQL is part of the webviews API (UIWebView or WKWebView). I suggest you to search stackoverflow etc. for WebSQL in WKWebView or UIWebView on iOS. You may be lucky there.

Magu0013 commented 3 years ago

Yeah the problem is I already tried this. I asked on Stackoverflow and only found someone with same problem but no solution. I also asked directly in the apple developer forums and also got no response. It seems like no one has a clue about this.

breautek commented 3 years ago

If WebSQL no longer works in the webview then migrating data is going to be impossible without some plugin with some native code. Even then I'm not sure if is possible to migrate WebSQL.

There is a plugin that we used to migrate WKWebView local storage (with file:// based origin) to WKWebView using schemes (in this case... ionic:// scheme). I would expect the WebSQL physical files to be located along side of the LocalStorage directory or something, so that's where I'll be prodding around. I think you can use xcode to browse through the app's private data.

Even if the WebSQL physical files are there you may not be able to read it. I don't know what the format is. Local storage files are just simply an sqlite database.

https://github.com/totalpave/cordova-plugin-migrate-localstorage/blob/master/src/ios/MigrateLocalStorage.m

If happen to find the websql file and you hexdump it. Look at the first address line. If you see something like:

5153 694c 6574 6620 726f 616d 2074 0033 then you're working with a SQLite 3 database.