简体   繁体   中英

Cordova SQLite with ionic native in angular 1

I'd like to add DeepLinking to my hybrid application which I found out works with ionic-native.
I have a working project with SQLite datebase tested on iOS and android but when I include ionic.native in my app module it throws an error.

app.module: angular.module('myApp', ['ionic', 'ionic.native'])
app.run: openDB is at 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

I guess it's related to ionic-native's plugin list since it has SQLite also.

I could solve the problem by changing the way of opening the database. At the time when I was implementing the cordova SQLite database had problems on iOS with window.sqlitePlugin.openDatabase() but was not using ionic.native so back then using the $cordovaSQLite.openDB() solved my problem since it calls directly the plugin.

The way I open the db now:
ionic.Platform.ready(function () { db = window.sqlitePlugin.openDatabase({name: 'qpi.db', location: 'default'}); });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM