Ionic 2 / Angular 2 Timer

I am using the Observable timer right now to open the modal for the first 15th minute and then every 24 hours.

 presentUpgradeModel() {
    let timer = Observable.timer(900000, 86400000);
    timer.subscribe(t => {
      if (this.shouldShowUpgradeModal) {
        this.openUpgradeModel();
      }
    });

  }

      

I'm just wondering if this is consuming too many resources in the background or if there is a better way to do this? His mobile app is so reluctant to consume a lot of background processes.

Basically, I just want modal popups every 24 hours or so.

Would setTimeout be better for this?

+3


source to share


1 answer


Well its not only about timers its also about background app on mobile phones. First of all, if the user closes the app, it will be paused and it won't work.

If you want such messages to resemble Push notifications.

Of course, you can use plugins to prevent background sleep, but then your application will use up the battery.



So, to summarize, it is better to use Push notifications to notify users, or you can use a plugin, but then no matter what your app will use the dough all the time

Finally, I will use observables for mystery related things

PS. I forgot about the native plugin called Local Notifications . This allows you to schedule and even if the application is closed, it will still call the process. it could go

0


source







All Articles