-1

I am developing an app that has refills lives every 5 minutes. What is the best way to check the time since the last refill so that the user cannot trick the system by changing the time on their device?

For an example, look at Candy Crush. Changing the system time on there gives you extra lives, and this is what I need preventing. I have gone through with this link iOS Development - Check Internet Time but in that I am getting date and time for UTC how can I get the time and date for IST.Even I used http://www.timeapi.org/ist/now now I am getting incorrect time.How can I achieve it??THank you in advance

Community
  • 1
  • 1
uttam raj
  • 67
  • 1
  • 10
  • You need to use NTP. – trojanfoe Dec 24 '15 at 10:51
  • You could just get the time in UTC, from timeAPI, and use `NSDateFormatter` to create a `NSDate`. Since a `NSDate` is not timezone aware you can use an other `NSDateFormatter` to present it too the user in the device timezone or IST if you really want. – rckoenes Dec 24 '15 at 11:04

2 Answers2

0

You can make an entry on your web server at the time the energy level is down in your app. After every refresh (you can customise your refreshing logic) you can check from server "Is the time of 5 minutes is over for this particular user so that i can allow him to play more". User can't trick your server time.

Rahul Mathur
  • 872
  • 1
  • 7
  • 20
-3

Try this

NSDate* datetime = [NSDate date];
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; // Prevent adjustment to user's local time zone.
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:SS.SSS'Z'"];
NSString* dateTimeInIsoFormatForZuluTimeZone = [dateFormatter stringFromDate:datetime];

Hope it helps.

Pradumna Patil
  • 2,180
  • 3
  • 17
  • 46