4

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?

amol01
  • 1,823
  • 4
  • 21
  • 35

1 Answers1

1

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.

Josh
  • 17,834
  • 7
  • 50
  • 68
  • Both are returning IDBFactory which I guess means they are not null and iOS supports both. I have heard about the bug, but is there any work around, or API to fix it? – amol01 Dec 05 '14 at 08:03
  • If they are not null then you probably do not need to use the shim. There is something else that is wrong with your surrounding code that is causing the indexedDB variable to not be defined. Maybe a version parameter to indexedDB.open is required. Maybe using window is doing something unexpected. Try using a database name without a space in it. – Josh Dec 05 '14 at 14:40
  • I just tried everything: version number, trying all combination of database name, still the same error. Works perfectly fine with other devices, and browsers, but not iOS 8.1 with its Safari. It works with Safari on MacBook Pro, which is a bit weird though to me. – amol01 Dec 05 '14 at 15:09