amol01
amol01

Reputation: 1863

IndexedDB with iOS 8/ Safari

We have a testcase to test indexeddb with different browsers and OS. It is just simple test:

     open database, add some data, retrieve some data

That is it. It is working perfectly in Chrome (39), Firefox (new versions), MacBook Pro with OSX 9.5, Android based Browsers.

When we try with Ipad3 with iOS 8, the page is not doing anything. And we can not see any errors too.

Any ideas, how to fix the problem?

We used indexeddb.shim.js file that suppose to help, but still does not work.

 if (!window.indexedDB) {
     window.alert("Your browser doesn't support a stable version of IndexedDB.")
 }

 var request = indexedDB.open("kitta db1");

 request.onupgradeneeded = function() {
       //create Store and etc
 };

 request.onsuccess = function() {
   db = request.result;

 };

The error in iOS 8:

Type Error: null is not an Object on the line:

 var request = indexedDB.open("kitta db1");

Any idea how can I fix it?

Upvotes: 4

Views: 4590

Answers (1)

Josh
Josh

Reputation: 18690

It looks like the variable indexedDB is null. The polyfill does this:

e.indexedDB=e.indexedDB||e.webkitIndexedDB||e.mozIndexedDB||e.oIndexedDB||e.msIndexedDB 

So it is setting the variable to one of those values. If those values are all undefined/null, then the indexedDB variable remains null.

A simple way to test whether any of these variations have values (less Microsoft, Opera, and Mozilla) would be something like the following:

console.log('indexedDB: ', indexedDB);
console.log('webkitIndexedDB: ', webkitIndexedDB);

If webkitIndexedDB is undefined and indexedDB is undefined, then iOS apparently does not support indexedDB.

A simple search on caniuse.com says that indexedDB on iOS8 and iOS8.1 is supported but buggy.

Upvotes: 1

Related Questions