I have the following line of code, in an Ionic app, that fires when the platform is ready (below). When testing it on Chrome, it works fine and the log fires ("Ionic Serve Syntax"). On my mobile phone, in Safari, nothing happens, basically nothing fires - seeming like the database does not even open.
If the database was not installed correctly, it should not work in Chrome too then right? Or did I not install the SQlite correctly?
I am also testing it on a Cloud platform (cloud9), could that have something to do with it?
.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();
}
if(window.cordova) {
// App syntax
console.log("App syntax")
db = $cordovaSQLite.openDB("starter.db");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people (id integer primary key, firstname text, lastname text)");
} else {
// Ionic serve syntax
console.log("Ionic serve syntax")
db = window.openDatabase("starter.db", "1.0", "My app", -1);
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people (id integer primary key, firstname text, lastname text)");
}
//$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS team (id integer primary key, name text)");
});
})
Aucun commentaire:
Enregistrer un commentaire