Which would be the best approach to prevent that an app could be used after some days of "testing"? Lets say I have to distribute my app using Ad Hoc distribution, the user has only one week to test, after that he should not be able to use the app.
Thanks in advance.
I do the following to put a time limit in the app for beta testing:
#ifdef BETA
NSString *compileDate = [NSString stringWithFormat:@"%s %s", __DATE__, __TIME__];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"MMM d yyyy HH:mm:ss"];
NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
[df setLocale:usLocale];
NSDate *aDate = [df dateFromString:compileDate];
NSDate *expires = [aDate dateByAddingTimeInterval:60 * 60 * 24 * 7]; // 7 days
NSDate *now = [NSDate date];
if ([now compare:expires] == NSOrderedDescending) {
NSAssert(0, @"Sorry, expired");
}
#endif
where BETA
is a compile flag I set only for adhoc builds.
I put this code in the applicationWillEnterForeground:
app delegate method.