apache / cordova-ios

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

Is webSQL really deprecated in iOS 14 and will be unusable? #970

Closed appzer closed 4 years ago

appzer commented 4 years ago

Hello, i only have a simple question, one of my older apps made with cordova use the webSQL API! With the latest beta5 release of Xcode i get the notice that webSQL is deprecated and my app do not work anymore!

Is webSQL really deprecated in iOS 14 and will be unusable?

If so, can I get around this with a plugin, or do I really have to switch to a different storage system!

Regards Kevin

dpogue commented 4 years ago

WebSQL has been a deprecated web standard since 2010.

On iOS, WKWebView does not support WebSQL as of iOS 13. UIWebView (which is also deprecated and will not be accepted by Apple soon) removes support for WebSQL when building for iOS 14.

breautek commented 4 years ago

WebSQL has been deprecated for a very long time now. The last W3 draft was in November 2010.

Your closest alternative is probably using an SQLlite plugin, but you'd have to have a migration process to transfer data from websql to the sqlite database.

do I really have to switch to a different storage system!

Strongly recommend switching to a different storage system.

appzer commented 4 years ago

thanks a lot

appzer commented 4 years ago

But on Apples iOS Safari page there are no changes about webSQL: https://developer.apple.com/documentation/safari-release-notes/safari-14-beta-release-notes

I test it with iOS 14 Beta 1-4 it not worked now with beta 5 it worked again!

It is possible that websql works on iOS14?

timbru31 commented 4 years ago

It's possible that they just shipped a broken implementation in their previous betas. But you should really move forward and not rely on WebSQL anymore. (See e.g. https://developer.apple.com/documentation/safari-release-notes/safari-13-release-notes, it already stated that support was removed)

SureshMangal commented 3 years ago

is there a way to for migration process to transfer data from websql to the sqlite database in iOS 14 and later

breautek commented 3 years ago

is there a way to for migration process to transfer data from websql to the sqlite database in iOS 14 and later

If WebSQL still works, then the easiest way is just to use whatever WebSQL APIs to dump the data from the WebSQL database to another storage mechanism. Doing this ASAP while WebSQL still exists probably should be your top priority so that when users run their app, a migration process can be done to migrate from WebSQL. Depending on the nature of your app and/or data you may need to create a screen that tells the user that a one-time data migration is taken place and they need to wait for it to be completed before they can use the app.

Personally I'd suggest avoiding using browser-based storage solutions (local storage, indexedDB, e.g.). While they may be easier to use, they are still subjected to the browser security policies (by origin) which causes problems when you need to switch webviews (e.g. the recent UIWebVIew to WKWebView that was forced on us).

For simple data, you can probably just use a flat file, like a JSON file written to the local file system using cordova-plugin-file. For larger complicated structures (which I assumed is why you were using WebSQL in the first place), then I'd recommend a third-party SQLite plugin, e.g: cordova-sqlite-storage

If WebSQL database is not available, then native development knowledge will probably be valuable here but you can try poking around inside the WebKit folder, which should exist inside your NSLibraryDirectory.

I've never used WebSQL but I've migrated local storage from WKWebView null (file) origin to WKWebView url scheme origin (e.g: ionic://localhost). The WebKit folder has a folder for local storage data, so I'm assuming there are directories for other web storage mechanisms as well. Then of course, if the websql storage files can be found, then it's a question on whether they are readable or not.

SureshMangal commented 3 years ago

thanks a lot @breautek