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.
To get the installation date, check the creation date of the Documents folder.
NSURL* urlToDocumentsFolder = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; __autoreleasing NSError *error; NSDate *installDate = [[[NSFileManager defaultManager] attributesOfItemAtPath:urlToDocumentsFolder.path error:&error] objectForKey:NSFileCreationDate]; NSLog(@"This app was installed by the user on %@", installDate);
To get the date of the last App update, check the modification date of the App bundle itself
NSString* pathToInfoPlist = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"]; NSString* pathToAppBundle = [pathToInfoPlist stringByDeletingLastPathComponent]; NSDate *updateDate = [[[NSFileManager defaultManager] attributesOfItemAtPath:pathToAppBundle error:&error] objectForKey:NSFileModificationDate]; NSLog(@"This app was updated by the user on %@", updateDate);
NSDate *installDate = [[NSUserDefaults standardUserDefaults]objectForKey:@"installDate"]; if (!installDate) { //no date is present //this app has not run before NSDate *todaysDate = [NSDate date]; [[NSUserDefaults standardUserDefaults]setObject:todaysDate forKey:@"installDate"]; [[NSUserDefaults standardUserDefaults]synchronize]; //nothing more to do? } else { //date is found NSDate *todaysDate = [NSDate date]; //compare todaysDate with installDate //if enough time has passed, yada yada, //apply updates, etc. }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With