2016-11-09 92 views
0

我想將DeepLinking添加到我的混合應用程序,我發現它適用於離子本機。
我有一個在iOS和Android上測試的SQLite數據庫的工作項目,但是當我在應用程序模塊中包含ionic.native時,它會引發錯誤。
科爾多瓦SQLite與角1中的離子本機

app.module:angular.module('myApp', ['ionic', 'ionic.native'])
app.run:openDB是app.js:207
ionic.Platform.ready(function() { db = $cordovaSQLite.openDB({name: 'my.db', location: 'default'}); });

Error: Uncaught TypeError: undefined is not a function. app.js:207

The blog post about ionic deep linking I try to put into practice
Ionic deep linking plugin docs for Ionic/Angular 1

我想這是與離子相關-native的插件列表,因爲它也有SQLite。

+0

你能告訴您更多的代碼,尤其是依賴注入的一部分嗎?在你的情況下,這可能是'run()'函數。 – Dexter

+0

當然,我所做的只是添加'ionic.native'到模塊中。在此之前,一切工作正常。 '.run(函數($ window,$ ionicPlatform,$ rootScope,$ state,$ cordovaSQLite,$ ionicPopup,$ ionicHistory){...}'和一些服務也包括在內。 – MagicDragon

+0

嘗試在'deviceready'事件中使用openDB –

回答

0

我可以通過改變打開數據庫的方式來解決問題。在我執行cordova時,SQLite數據庫在window.sqlitePlugin.openDatabase()的iOS上遇到了問題,但是沒有使用ionic.native,所以使用$cordovaSQLite.openDB()解決了我的問題,因爲它直接調用插件。

我現在開的DB方式:
ionic.Platform.ready(function() { db = window.sqlitePlugin.openDatabase({name: 'qpi.db', location: 'default'}); });