How/when do providers run?

I apologise for the lack of technical knowledge if this doesn’t make much sense, I am fairly inexperienced with Ionic and web technologies as a whole if I’m honest.

I am using multiple providers, one for getting data from an SQLite database and another to handle notifications.

The notifications provider triggers random notifications if notifications are not paused (e.g. the user does not want to be disturbed). As the following notifications are not created until the previous notification has been responded to, and I am doing this using LocalNotifications.isScheduled().then()… in app.component.ts. This triggers a new notification as soon as one has gone if the notifications are not paused which is decided on a boolean that is returned from the database.

The settings provider opens the database and gets all of the data (as you probably guessed), but it does this too late and the method has already been called before the database is opened and consequently returns null.

I want to know how I can make the settings provider, or at least the opening of the database, happen before the notification provider decides whether to schedule another notification as I’ve found that calling a method in app.component.ts before calling the setNotification() method in the notification provider makes no difference to it.

Any help?

One approach would be to have the database provider expose a promise and the notification provider wait on it:

class DatabaseProvider {
  ready: Promise<any>

  constructor(plat: Platform) {
    this.ready = plat.ready().then(() => {
      return someFunctionThatOpensDatabaseReturningPromiseWhenDone();

class NotificationProvider {
  constructor(db: DatabaseProvider) {
    db.ready.then(() => {

Thanks, hadn’t thought of that! you’re a hero