Is it possible to use indexedDB in a Cordova iOS application?

I get InvalidAccessErrorwhen I try to open an indexed database in an iOS application for Cordova.

Platform:

  • cordova: 5.4.1
  • cordova-ios: 4.0.1
  • iOS 9.2 (simulator and real device)

I already added a plugin to use WKWebview , which made the indexedDB object at least specific, but an error was selected. The code works in chrome, safari and mobile safari if I run it through my own cordova web server.

config.xml is as follows

<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
    <allow-intent href="market:*" />
</platform>
<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
</platform>
<feature name="CDVWKWebViewEngine">
    <param name="ios-package" value="CDVWKWebViewEngine" />
</feature>

<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />

and I try to open indexedDB with the following:

openDb: function() {
    var openRequest = window.indexedDB.open(DB_NAME, DB_VERSION);
    openRequest.onupgradeneeded = function(event) {
        console.log('upgrade needed');
        console.log(event);
        myIndexDb = event.target.result;
        var options = {
            autoIncrement: true,
            keyPath: 'key'
        };
        var objectStore = myIndexDb.createObjectStore(DB_STORE_NAME, options);
    };
    openRequest.onerror = function(event) {
        console.log(event);
        console.log('indexDB open Error!');
    };
    openRequest.onsuccess = function(event) {
        console.log('open success');
        myIndexDb = this.result;
    };
    openRequest.onblocked = function(event) {
        console.log('request is blocked');
        console.log(event);
    }
}
+4
source share
2 answers
0

cordova-plugin-wkwebview-engine IndexedDB -.

wkwebview-engine-localhost, , -. ,

cordova plugin add https://github.com/apache/cordova-plugins/tree/master/wkwebview-engine-localhost
0

Source: https://habr.com/ru/post/1622952/


All Articles