I'm trying to fetch the time of my app from the firebase servers using FirebaseFirestore.Timestamp() so that my users are unable to change the device time and fool the app into giving out daily credits sooner than they should get them.
To that end, I have used the following code, but this still returns the time on the device itself.
What I want to achieve is that whenever a button is pressed, getTime() gets called and prints the time as per the Firestore server, and not as per the device on which the app is installed.
My code is as below:
func getTime() {
let time = FirebaseFirestore.Timestamp()
print(time)
// Prints <FIRTimestamp: seconds=1586518212 nanoseconds=6677150>
let RequestedDate = time.dateValue()
print("\(RequestedDate) CHECKHERE")
// Prints 2020-04-10 11:30:12 +0000 CHECKHERE, which is the wrong date I set using the device itself.
let calendar = Calendar.current
let componentsss = calendar.dateComponents([.day, .hour], from: RequestedDate)
print(componentsss)
// Prints the components of the device time.
}