3

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?

KleggerKoder
  • 161
  • 1
  • 10
  • I remember seeing someone else complaining about the same thing recently. Sorry, I can't seem to find the link. – dumbmatter Oct 02 '14 at 22:37

3 Answers3

2

Known issue. Amongst other iOS8 IndexedDB bugs.

Raymond Camden
  • 10,661
  • 3
  • 34
  • 68
1

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...

solo999
  • 171
  • 1
  • 4
0

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

Masood Moshref
  • 370
  • 4
  • 9