【发布时间】:2016-01-05 16:46:34
【问题描述】:
当我尝试在我的 cordova iOS 应用程序中打开索引数据库时,我收到了 InvalidAccessError。
平台:
- 科尔多瓦:5.4.1
- cordova-ios:4.0.1
- iOS 9.2(模拟器和真机)
我已经添加了Plugin to use the WKWebview,它使 indexedDB 对象至少被定义,但是抛出了错误。如果我通过科尔多瓦自己的网络服务器运行该代码,它可以在 chrome、safari 和移动 safari 中运行。
config.xml 看起来像这样
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
我尝试用这个打开 indexedDB:
openDb: function() {
var openRequest = window.indexedDB.open(DB_NAME, DB_VERSION);
openRequest.onupgradeneeded = function(event) {
console.log('upgrade needed');
console.log(event);
myIndexDb = event.target.result;
var options = {
autoIncrement: true,
keyPath: 'key'
};
var objectStore = myIndexDb.createObjectStore(DB_STORE_NAME, options);
};
openRequest.onerror = function(event) {
console.log(event);
console.log('indexDB open Error!');
};
openRequest.onsuccess = function(event) {
console.log('open success');
myIndexDb = this.result;
};
openRequest.onblocked = function(event) {
console.log('request is blocked');
console.log(event);
}
}
【问题讨论】:
标签: ios cordova mobile-safari indexeddb wkwebview