May I ask that, what would be the goal here? To show an offer or a quote, or something else? Would you need to show at the start after opening the app or just only after arriving into the home screen?
Instead of the component, I think you could use date properties to build a visibility condition to first check if the current time is between and next to check if the boolean is false. @Victor, since you’re an legendary expert with dates, maybe you could share some information here?
Ok, so what I could suggest, with some explanations. I don’t have an opportunity to test this so it is theoretical.
The time is stored in Adalo as a number of days since 1/1/1970. The fractional part represents number of hours.
The current time is taken from the user device. The timezone is taken into the account when displaying time (as well as locale of the user device).
When storing time in DateTime property, it will be stored as described in #1, related to GMT+0. But it will be displayed according to the user’s device timezone.
So we could add 2 datetime properties to some collection, e.g. Users collection, name them: currenttime and starttoday. With the action Update Logged-in User, we can store current time and start of today respectively.
We can also add a 3rd number property, call it, say, nbhours. With the second action we can Update Logged-in User → nbhours, set it to Logged-in User → currenttime - Logged-in User → starttoday. Pay attention to “-” - this is minus sign.
What I expect as a result, is having a number between 0 and 1, which represent the %% of hours which already passed in this day. E.g. 0.5 means noon, 0.25 means 6am, etc.
In order to check if this works, you can add a label and display this property.
As we now have time, checking whether it’s AM or PM is trivial (could extend that to morning afternoon evening etc.). For AM/PM I would do these manipulations on some “loading” screen, and then have 2 labels with visibility conditions using comparison with number. If a message needs to displayed only once, the boolean property can be updated at the exit action of the screen (also conditional), and each label should be wrapped into a group which, in turn, also displayed conditionally using morning_shown / evenining_shown.
Again, I can’t test it right now but I hope this gives some inspirational ideas.
Victor’s approach with the time calculation is accurate and native (using Logged In User updates + nbhours = currenttime - starttoday gives % of day passed as 0-1).
In order to implement this approach practically as a popup that shows once per day AM/PM:
On (Loading) or (Home) screen load:
Update Logged In User: (currenttime = Now), (starttoday = Start Of Today), nbhours = (currenttime - starttoday).
Add the following (True/False) properties on Users collection: morning_shown, afternoon_shown (or one “popup_shown_today”) depending on how you’d like the popup to act.
Add the following visibility conditions to the Popup:
If nbhours < 0.5 (AM) AND morning_shown = false => show pop-up.
If nbhours ≥ 0.5 (PM) AND afternoon_shown = false => show pop-up.
On pop-up “Close” action: Update Logged In User => morning_shown = true (or afternoon_shown = true).
This way, the pop-up shows only once per time block per day.