1

So far we have upgraded UIWebView to WKWebView, most feature are pretty good but when we try to create database with html5 openDatabase api we encounter "Security Error", for now we want to use indexedDB to instead of webSQL.

Could you encounter the same "security error" with openDatabase, how to do you fixe it?

Thanks

hugh
  • 31
  • 4
  • Possible duplicate of [WKWebView gives SecurityError when bundling html and javascript with app](http://stackoverflow.com/questions/25685213/wkwebview-gives-securityerror-when-bundling-html-and-javascript-with-app) – Connor Pearson Jul 27 '16 at 10:10

3 Answers3

0

WebSQL is deprecated, WKWebView doesn't support it. I suggest to use IndexedDB.

soflare
  • 751
  • 5
  • 16
0

solflare is correct, WKWebView does not support WebSQL, however the IndexedDb implementation from Apple is very very poor. See this thread Primary Key issue on iOS8 implementation of IndexedDb

Community
  • 1
  • 1
Jonathan Smith
  • 2,390
  • 1
  • 34
  • 60
0

I've made a 'plugin' that allows you to use WebSQL (more an implementation of it) in the WKWebView. It can be found here

https://github.com/ajwhiteway/WKWebSQL

import WKWebSQL
.
.
.
var webView = WKWebView(frame: view.frame, configuration: WKWebViewConfiguration())
WKWebSQL.LoadPlugin(webView)

To get it loaded into the page. Versioning isn't really supported at this time. Feel free to add it. This doesn't fix the local storage issue, is just an implementation of WebSQL that uses SQLite and WKWebView.

I recommend only on iOS 9+. In iOS 8 the javascript evaluation creates new contexts taht have to be garbage collected and will choke your app for memory.

Ajwhiteway
  • 986
  • 1
  • 9
  • 23