Help build a timer that works when the screen is locked

The timer is ready and working. But every time the user locks the screen the timer stops. Is there a way for the timer to continue working when the screen is locked?

2 Likes

The thunkable timer does not seem to work in the backgroundļ¼ :sob:
But ai2
can.

1 Like

@Balanced_Kitchen @tony.ycy.program

Check this out

4 Likes

An interesting solution. I also thought to use the local time, but I assumed that there is an easier option :slight_smile:

1 Like

I added synchronization with the local time and now everything is OK. However, everything turned out to be in vain because I have an event when the timer becomes 00:00:00, which cannot happen when the screen is locked. I will build the timer in html. The web viewer I think works in background mode.

2 Likes

The html file is ready. Will anyone help me integrate the features into it Post Message and Receive Message. With Post Message you need to set the time in seconds and Receive Message to trigger a play sound and this should happen when the timer is 00:00:00. I admit I have no idea how to do it.
timer.txt (4.6 KB)

https://x.thunkable.com/copy/983001297d524c97619314788a5e711f

2 Likes

It turned out that the web viewer does not work for iOS either. Obviously it is impossible to make a timer with Thunkable. I do not understand why basic sensors do not work in the background, given that good practices show the opposite. I hope someday this will change!

2 Likes

The stored variable works. @darren has an example that is worth looking at.

3 Likes

If I donā€™t bother you, can you send link!

2 Likes

Here you are

2 Likes

Timer synchronization is not a problem for me (when restarting the application, if the timer is still counting down). The problem is if the timer has expired while the application is in the background. Then I have an event (such as a bell ringing) that will never be triggered. I am looking for a solution to this problem. So far I have not found and therefore option two - no timer :slight_smile:
Thank you though!

2 Likes

The first thing that comes to mind for such situation is to add an event to Google calendar and let it manage the alert/notification for the user.

3 Likes

If you are attempting to have an event fire with the phone closed, that canā€™t happen as a thunkable app has little to no real control over background events beyond watching/waiting for push notifications.

The method shared is the only way to have a count up or count down timer (for now) that works with the phone closed. The issue being they canā€™t fire events with the phone closed but because itā€™s a math operation and not a running event, you can in fact keep time this way. A traditional timer is a ā€œrunning eventā€ and all events stop running when the app enters the background.

2 Likes

Here it is

1 Like

I will definitely try it. Thank you for the video.