How can I have a timer to work in the background, to keep track of user activity?

So I'm creating an app that works as a timer. A user has a start,pause, and end buttons. When he presses on start a timer is activated, on pause is paused and end it ends the timer. The purpose of the timer is to send reminders every custom amount of time to do an activity.  I can't use a widget, cause the user can render different pages in the app, as also it restarts when the page is refreshed. Another possibility is using scheduled_event. What is the best method to achieve this?
1 answers

Hi Wiam,

I would associate a non-persistent entity (e.g. Timer) to a Session and capture the Start (DateTime) there. You make use of a snippet which you place on all the applicable pages, or put that in the Layout you use for all these pages (for example Atlas_Topbar).

In this situation, the same Timer object is shown on all your pages.

In the snippet: put a listview retrieving the Timer(s) over association from Session and set page size to 1. Create an object somewhere in your navigation flows, such that 1 Timer is created if it doesn't exist yet.

You can play around with buttons:

  • 'start' set Start on ['%CurrentDateTime%']
  • 'end' set End on ['%CurrentDateTime%'] and displays the secondsBetween or minutesBetween
  • 'reset' clears all attributes

If needed you can make use of a MicroflowTimer or MicroflowRepeater widget to recalculate the number of seconds/minutes past and show that. Preferably use nanoflows to minimize the load on the server.

Good luck!