mercredi 1 avril 2015

$cordovaSQLite not working in app, only on web

I have no success in initiating the ngCordova plugin $cordovaSQLite. Basically, in the code below, the window.alert("Trying DB") does not even fire. I have no idea what is happening...


The thing is, that it does work fine on the web (testing it in chrome), but not when deployed. What could be the issue?


app.js (subset)



var db = null;

angular.module('starter', [
'ionic',
'ionic.utils',
'ngCordova',
'angular.filter',
'starter.controllers-information',
'starter.services-cordova-sqlite',
'starter.directives'])

.run(function($ionicPlatform, $cordovaSQLite, DebugConsole) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}

//

window.alert("Trying DB...")
DebugConsole.log("Trying DB...")

if(window.cordova) {
// App syntax
db = $cordovaSQLite.openDB("starter.db");
} else {
// Ionic serve syntax
db = window.openDatabase("starter.db", "1.0", "My app", -1);
}

$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS team (id integer primary key, name text)");




});
})


The rest of my code looks like here: http://ift.tt/1GgEOuW


I deploy my app using Phonegap build. In my config.xml I have declared:



<gap:plugin name="com.brodysoft.sqliteplugin" version="1.0.6" />

Aucun commentaire:

Enregistrer un commentaire