Find correct time on iOS device - ios

I want to find out correct time on iOS devices even though user have set wrong time manually.
In the setting->General->Date & Time there is option of Set Automatically if that option is uncheck by the user then how can i find the correct time programmatically.

Use NTP protocol for getting a current time or serve a time from your server and get it on application launch.
Apple doesn't provide by default any way to get time from NTP unfortunately and all time related function are using local time that user can change.

I have a 'web service' on my site which serves you the current time in milliseconds since the Unix epoch, one request, one response, nothing else.

I think this is the wrong place for this question. Try Apple's forums.
Because there is no way to get current time form ios device when user update time manually.
Sweet & smart .........

Related

Get time difference in iOS when in offline mode

I have an app which works both offline and online. I have a request from the client to embed a functionality which will disallow the user from using certain functionality after some days, 7 days, for example.
If online I can easily achieve this task by comparing the time-interval between server time.
But in offline mode, this has been a problem. I have tried to achieve this by saving server timestamp in USerDefault and when the app comes in the foreground, compare the current NSDate with the one saved to get time interval. But, what I found is this can be hacked easily by manipulating the date and time in Settings and those functionalities in app works perpetually.
Another solution I have thought is to disable the app if date time is not set to automatically in the setting. But, found that Apple has not disclosed the API to access date and time.
I have searched for other answers on the internet, but could not find the solution to fix this issue. Also, tried some offline game app to check but found that I can change date and time to manipulate their functionality.
So, isn't there any robust solution to fix this issue? Any help is highly appreciable.
you can manage timings on the server through API calls when the user
goes offline or log out or something. so you can easily get to know
your exact timing and it is also not hackable :)

How do you modify an app that's on the app store without making your users update the app?

I am working on an mobile app that requires me to change the text displayed either on a weekly or a monthly basis, but I don't want to require the users to have to update the app every day or every week in order to see the changes. I would love suggestions on how to do this.
As a high-level answer, check the device date and display the proper text, if it is fixed and known ahead of time.
If not, have a file or api call send down the information and the next date of when the server should be checked for the next set of data.

How to see if an iphone is synced if an NTP server?

I am coding in Xcode 6.1.1 with objective-c.
In my app it is critical that I use the correct time.
I only want the app to use the time of the device when the time is synced with the servers.
If an user is somehow using his/her own "weird" time the app should detect that and tell the user to switch back to use the app.
I know there is NSSystemClockDidChangeNotification, but that only gives back when the time is changed. It does not give back what the change was and if the user switched to "custom" time or synced back to an NTP server.
Question: How do I detect if an user is connected to an NTP server or not?
Maddy is right that you can't specifically find this out from iOS.
However, in the past I've delivered a client for a premium subscription service that had a similar need to know if the user was messing with time. In particular we needed to verify this when there was no network available, in order to prevent the user from accessing premium content after their subscription had lapsed. The very simple mechanism we used was as follows (IIRC):
every time the app launches or comes in from the background, record the current time (eg: in NSUserDefaults)
compare the current time to the last recorded time--if the current time is earlier than the last recorded time, force the user to go online and sign in to the service.
I don't claim it is 100% foolproof, but for our purposes we felt it was good enough to prevent users from trying to circumvent time-based restrictions on accessing premium content.

iOS8 Today Extension: Detect removed or added today extension

I would like to know how to detect when user removes or adds today extension. If Apple does not have any method to do that, please suggest some ways for me to detect it.
Thank you very much for your time to answer my question.
You cannot detect when the user adds or removes a today extension. You can detect when an extension is run for the first time by reading/writing a value to NSUserDefaults, but that's about it.
If you don't need 100% accuracy, you could post [UIDevice currentDevice].identifierForVendor.UUIDString to an external API every time the widget is loaded. This would give you a time record of every time the user looked at your widget (while connected to the Internet). If you stop receiving regular updates from one UUID:
The user disabled your widget
The user removed your app
The user reset their vendor identifier
As I said, it won't be 100% accurate. That's about as close as you can get.

Keep track of time since last attempt of ______

I have a game where users can do a certain activity once per hour. How can I make sure it's been an hour since the last time they attempted something without them just changing their devices current time in settings?
Also, if I wanted to prevent the user from just deleting the app and re-installing it so they could constantly keep trying without having to wait to full hour is there any way I can store data on the device even after an app delete or would that have to be a server thing?
If I don't have a server can anyone think of a clever way to do this via Free in-app purchases or something?
The only way to persist data in a way that survives app reinstalls is to save it to the keychain. This works, because keychain data may be shared across multiple applications; the rest of your application's data is removed on uninstall.
If you need a reliable way to tell the current time, the device must be connected to the internet. In this case you would be able to check the current time using one of the time services through the NTP.
That sounds like exactly the sort of task you would need a server for.
When the user wants to perform this limited action, have them ask the server for permission. You can log the user's ID and request time, decide if they can execute the action, then return a small success/failure message. Works if they change their clock, works if they log in from a different device, works if they wipe the device data.

Resources