I’m making an app to memorize words.
After 10 minutes of learning a word, I want an alarm to sound and a notification window to appear.
This is a feature that tells you the time to review.
I want the app to run in the background. Is this possible in thunkable?
I’ve made a timer that counts down, but when I press the Home button to turn off the app, the timer doesn’t work. Open the app and it will work again. How can I make my timer work all the time?
Also
After memorizing words, I would like to sound the alarm 3 days later, 7 days later, and 30 days later.
How is this possible?
No, Thunkable doesn’t run code while in the background. You could have a timer that goes off after 10 minutes of using the app (in the foreground) or you could check to see how much time has elapsed when the app is re-opened – this latter method I’ve been trying to get working but haven’t figured out yet.
Onesignal doesn’t seem suitable for my app.
When a user learns a word, they need to register five notifications. When a user learns 10 words a day, 50 notifications must be registered. As the number of users increases, the number of notifications increases exponentially.
In addition, when offline, notifications do not come because of learning failure occurs.
I hope the notification works well even when offline.
I think I have a way to determine the amount of time an app has been in the background. I’ll upload a demo tonight or tomorrow morning, assuming it works.
It involves comparing the amount of time the app has been open to a timer saved to the cloud to the number of seconds since 1970.
In the meantime, here’s the algorithm I was going to try.
The idea is that the appTime is a countup timer (which is why I need it to work properly) that gets reset to 0 every time the app is opened. The elapsedTime is the difference between the number of seconds since 1970 and the startTime (which gets set at first run).
If the app was just opened/re-opened, appTime should be zero and we check to see if the elapsedTime is greater than zero (which means the app was re-opened instead of opened for the first time; I guess I could also check the first run boolean value…). If it is, then we use the elapsedTime as the background duration that we’re looking for. That is, the amount of time in seconds that the app has been in the background before being re-opened.
To check after 10 minutes is to check by time.
However, after 1 day, 3 days, 7 days, 30 days, etc., the check is based on the day.
So, to satisfy both of these conditions, it seems that the calculation method is based on the year, month, and day time values.
Isn’t it possible to use device blocks?
If you only calculate by time, you need to apply a formula that divides time by day.
Only then can you decide which day to show.
And with device blocks, don’t you need to calculate when you opened or closed your app?
I’m just starting to study this, so I don’t know what a good idea.
No, it’s best to determine time by using number of seconds since 1970. That way you’re not having to convert months and days and check for leap year and all kinds of other crazy things.
What I’m hoping to do is keep a timer running in the app and save the timer value every second. So if you close the app and then re-open it a while later, you can compare the “seconds since 1970” to the saved value from when the app was closed and you’ll be able to tell how much time elapsed between closing and re-opening the app.
The first time you click on a cat, it disappears.
The cat will appear after 5 seconds.
The second click will disappear.
Cats appear after 10 seconds.
The third click will disappear.
The cat will appear after 1 day.
I couldn’t find a way to add dates (year, month, day)
1970 blocks were used.
There is no background function but I used 1970 block
I can detect the passage of time even if I close the app.