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.
Neither one of the following codes work (after device is ready):
db = window.openDatabase("starter.db", "1.0", "My app", -1) // Nope
db = $cordovaSQLite.openDB("starter.db"); // Nope
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 have also tried to deploy it using Phonegap Build (and including the relevant plugin in my config.xml).
app.js
.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"); // DOES NOT WORK
$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); // DOES NOT WORK
$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)");
});
})