0

I am making a quiz app in which time is a very important factor. at particular time suppose at 11:00 AM game will start. so I am displaying countdown timer based on device time and 11:00 AM.

but a user can change their device time then the game will not synchronous between all users.

Is there anyways I could restrict a user to change time from the device setting or is there any other ways to check the correct time in iOS swift application.

Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50
user3202457
  • 135
  • 12
  • Possible answer: https://stackoverflow.com/a/27155212/5167909 – Faysal Ahmed Jul 30 '18 at 09:24
  • You can try to pull time from the web or your server. I don't think it's possible to restrict user changing their phone settings. Here's a [link](https://github.com/freak4pc/NSDate-ServerDate) to GitHub repo I found for syncing up time. – procyon Jul 30 '18 at 09:27

1 Answers1

0

If I were in your shoes, I would keep the client synced with server on an interval. Like sending requests to the server every few seconds, which contains the data that contains the last updates of the user answers. Then trace the answers and updates based on these client requests "on the server-side". That is what I mean by internally, You should check everything on the server-side. Then for example, you just simply reject the answers that are received after the end of the quiz.

For just accepting answers that are provided in time, you don't need an interval. Just send a request when a new answer is provided or an answer is edited.

The interval based syncing, has the advantage that user interface may also always be updated according the server time. You could fill the gaps using an interval function on the client, but everything will be updated and in sync with the server on intervals. You could also track any problems this way, like for example disconnection and reconnection. Changes in the network (for cheating purposes) and etc.

arashka
  • 1,226
  • 3
  • 17
  • 30