Ok, just getting to the brink of insanity! I have an SQLite database that I’m attempting to Create Tables on within platform.ready()
. This works awesome within Ionic Serve with chrome, no issues at all. iOS 9.3 is another story. Seems that the promise doesn’t always return and results in a white screen. Now if I close the app and retry multiple times it will eventually work. From what i can tell my root page is executing/loading before my tables are done with their promise. FWIW the app will not even return a message from the promise when it white screens.
Heres my initializeApp
within app.js
:
initializeApp() {
this.platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
this.storage = new Storage(SqlStorage, {name:'test', location:'default'});
this.dbTablesInit().then(() => {
console.log('complete');
});
});
}
Here is my dbTablesInit
dbTablesInit() {
console.log('Create Tables');
return Promise.all([
this.createAccountsTable(),
this.createAuditTable(),
this.createProductsTable(),
this.createObjectivesTable(),
this.createPhotosTable(),
this.createNotesTable()
]);
}
and here is an example of the first function Create accounts.
createAccountsTable() {
return this.storage.query("CREATE TABLE IF NOT EXISTS accounts (id INTEGER PRIMARY KEY, email TEXT, password TEXT, firstname TEXT, lastname TEXT, agent TEXT)").then((data) => {
if (data.res.insertId == 0) {
console.log('-- SQL: Accounts Table: Already Exists');
} else {
console.log('-- SQL: Accounts Table: Created New');
}
}, (error) => {
console.log('ERROR -> ' + error.err.message);
});
}
any advice would be appreciated. Is there any way to defer the first view loading until all the promises come back?
I’m using the latest version of cordova and ionic beta 7.