0

I recently had a iOS and Android app developed.

The app seems to use the users devices date and time, and as i offer rewards every 4 hours i find a lot of users may be simply changing their devices date and time to get these sooner - devaluing the in app purchases.

Is there a way to get either the networks date and time or query apples API to get the actual date and time?

Any advice?, without me having my own server and querying that - too much maintenance and no sure if it could handle the amount of requests.

Thanks

user2183216
  • 359
  • 3
  • 9
  • 22

3 Answers3

1

For IOS

you can use [NSDate networkDate]; for getting remote Date and Time.

For Android

No idea about Android.Sorry

Community
  • 1
  • 1
Sarat Patel
  • 856
  • 13
  • 32
0

FOR ANDROID GPS or Network timestamp can be retrieved by using the LocationListener in the Android Location API.

See the open-source GPSTest project for a fully working example: https://github.com/barbeau/gpstest

You can request to listen to either Network location updates:

lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);

or GPS location updates:

lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);

Then, when a location is passed into the LocationListener.onLocationChanged   method, you can read the timestamp from that location:

@Override
public void onLocationChanged(Location location) {
    Log.i("Timestamp", "New timestamp: " + location.getTime());
}
Another option is to make a request to a Network Time Protocol (NTP) server, which is completely independent of the device and cell network.
Shankar
  • 518
  • 5
  • 16
0

you can get it from time servers please check the existing post

How to get current time from internet in android

Community
  • 1
  • 1