0

Currently i am developing one gaming iOS application which i will give to some of my customer for demo.

But while distribution of my app i want to set an expiry mechanism in my app, so that it will get expire after "N" number of days. It means that (e.g. after 30 days) my app won't work.i can able to this by using system date & time, it means whenever my program starts i check today date and expire date.

The problem is if the user changes system time, my comparison won't be correct.

Also if user delete & reinstall the app,it wont work.

Any help or suggestion?

jscs
  • 63,694
  • 13
  • 151
  • 195
user1227928
  • 831
  • 1
  • 12
  • 27
  • 1
    You know that demos are not allowed in the App Store, right? – David Rönnqvist Apr 03 '13 at 19:24
  • Apple wouldn't let you do this. Try instead to make a "lite" version that has less features. Many apps do this to let people test it out. – Chris Loonam Apr 03 '13 at 19:25
  • @DavidRönnqvist , i know that, but this thing i am not going to put into appstore as of now , this is for internal client demo. – user1227928 Apr 03 '13 at 19:29
  • @user1227928 that is not the norm so you should make it more clear in the question. It is an important price of information. – David Rönnqvist Apr 03 '13 at 19:35
  • possible duplicate of [How can I locally detect iPhone clock advancement by a user between app runs?](http://stackoverflow.com/q/7122216) – jscs Apr 03 '13 at 19:36

2 Answers2

3

Look at Ad Hoc Distribution

Ad-hoc development builds last for 3 months, however if you want to add a time limit then you could:

Add a key-value in NSUserDefaults which stores the start date of the app (time taken from a webservice such as http://www.earthtools.org/webservices.htm#timezone) then every time the app enters the foreground check the time against it and if it is over the threshold then to cancel loading the app.

NSDate *now        = //load current datetime from restkit
NSDate *startDate  = [[NSUserDefaults standardUserDefaults] objectForKey:@"startDate"];
NSDate *futureDate = [NSDate dateWithTimeInterval:60 * 60 * 24 * 30 sinceDate:startDate];

if ([futureDate compare:now] == NSOrderedAscending) {
    //stop the application loading by loading a NIB and displaying a message.
}

I would recommend using RestKit to request data from the web-service.

Oliver Atkinson
  • 7,970
  • 32
  • 43
  • 1
    just for accuracy: 86400 seconds are not necessarily a day (daylight saving time). while for this task that might not be important, if you want a date EXACTLY in 30 days you date creation with NSDateComponents and NSCalendar instead. – vikingosegundo Apr 03 '13 at 20:23
2

When the app expires, store something in the Keychain to indicate this fact. Then just check that at startup, rather than the date.

Alternatively, you can have it check a web service you control.

Matt Green
  • 2,032
  • 2
  • 22
  • 36
  • keychain is an better option than nsuserdefaults, as information stored in it wont get deleted with the app. so with user defaults re-installing would ste back the timer. with keychain that wont happen. – vikingosegundo Apr 03 '13 at 21:36