1

I want to create a system that prevents the user from entering the app if the date and time are not configured properly on the user's device.

same as WhatsApp lock:

Thumbnail of YouTube video

Can this be done with a Firebase date and time as a reference?

Does anyone have any idea how this lockout is done?

Here's what I've done so far:

Calendar calFordDate = Calendar.getInstance();
SimpleDateFormat currentDate = new SimpleDateFormat("dd-MMMM-yyyy");
saveCurrentDate = currentDate.format(calFordDate.getTime());

Calendar calFordTime = Calendar.getInstance();
SimpleDateFormat currentTime = new SimpleDateFormat("HH:mm:ss");
saveCurrentTime = currentTime.format(calFordTime.getTime());
PostRandomName = saveCurrentDate + saveCurrentTime;
Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
  • You will need to use security rules on the backend, as the client device may choose its own time in order to fool whatever code checks the date and time in the app. – Doug Stevenson Jan 13 '19 at 05:03
  • Get the correct time from somewhere on the Internet, be it your own server or somewhere else. Search for how, this has been asked and answered a number of times. Compare with the device time as you get it from for example `Instant.now()` or `System.currentTimeMillis()` (the two mentioned options are independent of time zone). Allow a margin. – Ole V.V. Jan 13 '19 at 07:09

1 Answers1

0

Get DateTime through API is the way to prevent user with changed phone date time from accessing your app

Time zone must be put in consideration

Liar
  • 1,235
  • 1
  • 9
  • 19