Create a Secure Countdown | Unhackable | No Extension

Hello Everyone
Today I will show you how you can create a secure countdown of any duration. For this tutorial, you need to have a Firebase account with a basic knowledge of how to setup Real time Database.

Note : This method does not belong to me. It belongs to Pixi Bomb. She has made a tutorial on YouTube regarding this topic. She used Fusion Table which is now deprecated so i replaced it with Google Firebase.

==Components==


==Initialize Variables==


  1. timestamp_new : it will store newly fetched timestamp (UnixTimeStamp)
  2. timestamp_old : it will store old timestamp which will be fetched from Firebase
  3. new : It will store a copy of timestamp_new variable
  4. request : it will store request type (data or update). determines whether we will fetch data from firebase or update existing data.
  5. wait : store time duration of countdown in seconds
  6. T : acts as a switch
  7. ID : stores user specific id

==Procedures==


This checks whether the user is online or not. If the user is offline it shows an error message.


This loads data from Firebase


This gets timestamp from current date time
Second function extracts timestamp from obtained result

Note : Here I am using web viewer to get timestamp since I didn’t find any api for that. The url used for web viewer is obtained from this site : https://unixtime.co.za/
The data is loaded in the web viewer and I use JavaScript to get the data from web-viewer


This function changes the state of button. and turns the timer on or off


This clears all the stored data in variable. Used when user is disconnected from internet.

==Event Blocks==


When screen is initialized, we will check if the user is online or not and then load data from web viewer to get the current timestamp.


These blocks extract the timestamp from web viewer using JavaScript


These two blocks get the data from Firebase and store it in variables and toggle state of button and timer.


Starts the countdown


Updates old data in Firebase with the new one


Updates time every second


When user disconnects, we will stop the timer so the app does not crash. When user reconnects to the internet, the circle is again repeated.

Download AIA File : CountDown.aia (10.1 KB)
Download App : CountDown.apk (6.0 MB)

Note : You need to change Firebase Database URL and API key

If you want to change the time duration, just change the value of wait variable. Value should be in seconds
I hope you liked the tutorial. I know that I didn’t explain well but I tried my best. Let me know about your thoughts in the comments.

13 Likes

Great! :+1:

1 Like

Thanks @WatermelonIce. Check and let me know if there is any error

Awarded you the Tutorial writer badge :+1:

4 Likes

Thanks @Peter.

Nice guide @zainulhassan

1 Like

Hi Dear,
Can i use MYSQL Database for this Countdown Timer ?
If possible please explain How To ?

Database doesn’t matter for this you have to just get the data and put it in variable and it will do the countdown

4 Likes

Hi you use web viewer component in this timer but as far as I know that webviewer not allow in playstore.if I use this timer in my app and publish app in playstore then will be any problem ?

It is not web viewer ,just web component (an invisible component) it will extract the data

1 Like

web viewer components are changed how to use them with the new version

Can i get the javascript

1 Like

click me button not working