IndexedDB.open returns null on Safari iOS 8.1.1 and stops execution on Cordova. Even worse on iOS 8.1.2

I know that the implementation of IndexedDB in iOS is rather cumbersome, as are the shared IDs between different tables. However, it doesn't work for me. I'm trying to develop an iOS Cordova app that needs to use IndexedDB, so I created the following code:

window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction;
window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange;

var request = window.indexedDB.open("mydata");  //also tried open("mydata", 1) with same result
console.log('OPEN DB')
request.onupgradeneeded = function() {...};
request.onsuccess = function() {...};

      

When running this snippet in a Cordova app, OPEN DB

no print is shown, execution gets stuck when called indexedDB.open

(no error log or nothing at all). I thought it might be a Cordova problem, so I decided to run the same code in a regular Safari browser, although it should be the same as Cordova just uses UIWebview, which I think should use the same version of the web kite. as the browser.

When launched in Safari, the iOS 8.1.1

log is printed OPEN DB

, but it crashes on the next line due to the variable request

being null

. When run on, iOS 8.1.2

it crashes when called open()

, displaying a message in the log:

SecurityError: DOM Exception 18: An attempt was made to breach user agent security policy

What is $ @ #%! continues? I see some people complain about the error behavior, but I can't even open the DB, is this ok or what?

+3


source to share


1 answer


sadly indexedDB is not supported by UIWebView

http://www.sencha.com/blog/apple-shows-love-for-html5-with-ios-8



  • IndexedDB was added in iOS 8 Safari and "WKWebView"

  • IndexedDB not available in iOS 8 "UIWebView" or home screen apps

But you can try with the WKWebView cordova plugin http://devgirl.org/2014/11/10/boost-your-ios-8-mobile-app-performance-with-wkwebview/

+3


source







All Articles