Why apple didn’t provided isTimeZoneAutomatic() method?


As a developer, you might sometime want to have a method which will let you know if the user has changed the system time or not. This method will be very easy for developers to check if the user is trying to mess up with time and try to do something. For example trying to change time in Candy Crush game in order to stop waiting and get the reward soon. Well, since this is just a game and it is nothing big deal for user and for the company if user does this. However, the game company has now gone to online and now they cannot do this.

But what about this same scenario in business related apps. Let’s say for example in Attendance app, what if you can change time to past and do check in or check out. This is big issue for this kind of apps. At this moment, it would be great great great for developers if Apple just provided us a method similar to isTimeZoneAutomatic(). But sadly they haven’t. And there is a reason as well. 

I went through several testing regarding changing time in iPad. Once I tested on iPad, I knew new thing. Here is goes.

I was trying to get time based on time zone. So, I went to setting section and tried to change timezone from Nepal to US. And yes, I got time based on the that time zone. Only for example I have shown images of iPhone down below.

For this scenario, I have turned off Setting Time Zone to off. And I tried to set time zone to automatic. But in this case, my iPad was not able to set timezone to Nepal automatically because of 2 reasons.

  1. I didn’t give access to GPS for Time Zone as you can see it is turned off from second screen.
  2. My iPad is not cellular one. Which means, it cannot connect to SIM tower.

Images

As a result, iPad was not able to get my current time zone and was not able to show current date and time. It was still showing time zone of US which I previously selected.

This is the main reason which I think Apple actually didn’t created the method which we as a developers are looking for. May be, sometime Apple will. I don’t know. But based on my testing with time, I though this must be the reason behind not letting us powerful method. 

For android it is not a big deal. I tested in Android, even if the GPS is off and   Airplane mode is on, it was able to show current time zone when set to Set TimeZone automatically. Here is image from Android Setting section.

if(Settings.Global.getInt(getContentResolver(), Global.AUTO_TIME) == 1){
    // Auto time zone enabled
}else{
    // Auto time zone disabled
}

The code would look something like above. Well, if you are in Android platform, this will help you to figure out if user has changed the date and time or not. But for iOS developers, it is not possible to do this for now.

Well, there is a technique in iOS where you can get the method similar to this. But it will take a lot of effort for this. Let me know if you need help. I will be able to help.

Hope this blog was helpful to you. If you like it, please do share my blog. And let me know comments if you do have any queries. I just wanted to let people know what I went through and my thoughts about date and time.

✌️Peace ✌️

Thanks 

Leave a Reply

santoshm