How to catch the device back key event?

Hi @ChristopheHK

I had a use case where I had to implement a voting app. Imagine if you enter a voting booth, and you can cast your vote or not cast, but once you enter the booth and exit, you cannot enter the ‘voting booth’ screen again.

I used a logical variable in the user’s collection, whose value I set once that user visited the screen. You can do this in the editor by clicking on the screen -> ‘When user visits the screen’ -> Action, etc.

Navigation to that screen could be conditional, where your logical variable is of your choice (true/false, numerical, etc.).

Once the user voted, I then pushed the user to pass through a series of blank screens with transition as ‘none’, before ending up on the screen I desired. Again, with the same ‘When user visits the screen’ -> Action, etc., this time on the blank screen.

It worked perfectly.

The other way to do this is to not keep default action as ‘back’ via the back icon / left icon on the app bar. Instead you make the action as link to screen, even if it is the previous screen. This forces a new load of the screen and acts as a refresh.

Of course this doesn’t prevent navigation by hitting back button on user device. Only the first method I described above does.

I recommend either using a new flag column (in any table) which sets on sign-in + resets on visiting screen, or creating a ‘Flag’ collection which makes a new entry in the collection when user visits the screen. The checking condition for screen visibility is Logged in user -> count in the flag collection -> today = 0.

1 Like