Search code examples
iphoneios4

How to determine the date an app is installed or used for the first time?


I'm planning on opening up an in app store and I'd like to give existing users some of the items for free.

I thought of releasing an update which would store some informaion the first time the app is used, then release the "real" update that'd look if the app was purchased before, however, it's likely that not everyone will opt for the first update.

So, is there a way to find out when exactly a user has first installed (or used) the app ?

Update :

Thanks for the answers, but I should make the it less ambiguous :

I'm looking for a native call/anything similar to do it. Since the app is already on store and I haven't set up anything to store the data on the first version, an update will help me do what I want if all the users grab it before the second update is released : It'd be impossible to distinguish a new user from an existing one who had missed the intermediary update and has just updated to the most recent one.


Solution

  • My solution would be to check the last modified date of one of the files in the app bundle.

    NSString *sourceFile = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Icon.png"];
    
    NSDate *lastModif = [[[NSFileManager defaultManager] attributesOfItemAtPath:sourceFile error:&err] objectForKey:NSFileModificationDate];