KleggerKoder
KleggerKoder

Reputation: 161

Indexeddb is not working on iPhone IOS 8 from web app

I am having trouble with Indexeddb, it seems to stop working when you pin the web app to the home screen. Everything is working fine when running inside the safari browser. Is this a known limitation?

Upvotes: 3

Views: 2082

Answers (3)

Masood Moshref
Masood Moshref

Reputation: 380

IndexedDB is half supported for cordova! They only have a read only Database (totaly useless) But you can make a workaround, by using a polyfill for example Polyfill Indexeddb

The problem of the polyfill in case of ios8 is, that indexdb shim detect ,that indexdb is installed, but without knowing that they are a read only version, they use the window.indexdb and not the shim. Therefore you must forced to use the indexshim instead of window.indexeddb.

Open the code of the pollyfill find the code block:

   if ((typeof window.indexedDB === "undefined" || poorIndexedDbSupport) && typeof window.openDatabase !== "undefined") {
    window.shimIndexedDB.__useShim();
}
else {
    window.IDBDatabase = window.IDBDatabase || window.webkitIDBDatabase;
    window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction;
    window.IDBCursor = window.IDBCursor || window.webkitIDBCursor;
    window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange;
    if(!window.IDBTransaction){
        window.IDBTransaction = {};
    }
    /* Some browsers (e.g. Chrome 18 on Android) support IndexedDb but do not allow writing of these properties */
    try {
    window.IDBTransaction.READ_ONLY = window.IDBTransaction.READ_ONLY || "readonly";
    window.IDBTransaction.READ_WRITE = window.IDBTransaction.READ_WRITE || "readwrite";
    } catch (e) {}
}

and replace with:

   window.shimIndexedDB.__useShim();

you can use the indexedDB with window.shimIndexedDB

Upvotes: 0

solo999
solo999

Reputation: 171

window.indexedDB object in both 'Home Screen' and 'Cordova' web application on iOS 8 is null. And more - it is read only. So indexedDBShim has also failed...

The approach with window._indexedDB (https://github.com/axemclion/IndexedDBShim/issues/167) works for me...

Upvotes: 1

Raymond Camden
Raymond Camden

Reputation: 10857

Known issue. Amongst other iOS8 IndexedDB bugs.

Upvotes: 2

Related Questions