Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell if an iOS application has been newly installed or updated?

I have an application currently on the app store which I intend to submit an update for soon.

With this update I want to add code which will tell the app when it first runs application:didFinishLaunchingWithOptions whether it is:

  1. A new install from the app store.
  2. Newly updated from a previous version

There is no code in the app currently in the app store to handle this.
The application uses a SQLite database, but for reasons I won't go into here I don't want to use a check for its existence as a solution to this problem.

As a side question, without storing the data manually, is there an SDK I can use to query when an app was installed onto a device? (Preferably iOS 3.0 compatible)

I have seen a similar question, but none of the answers apply to working with existing app store code.

like image 903
Andrew Avatar asked Jan 06 '12 09:01

Andrew


People also ask

How do I know if my iOS app has been updated?

Open the App Store. Tap your profile icon at the top of the screen. Scroll to see pending updates and release notes. Tap Update next to an app to update only that app, or tap Update All.

How do you know when an app is updated?

At the top right, tap the profile icon. Tap Manage apps & device. Apps with an update available are labeled "Update available." Tap Update.

How can I check if an app is installed from a Web page on an iPhone?

Show activity on this post. iOS Safari has a feature that allows you to add a "smart" banner to your webpage that will link either to your app, if it is installed, or to the App Store. You do this by adding a meta tag to the page.


2 Answers

The following code may help to answer your side question about when an app was installed. I am unsure if the app bundle create date is the XCode build date or the download date as this is untested from app store.

NSString *bundleRoot = [[NSBundle mainBundle] bundlePath]; // e.g. /var/mobile/Applications/<GUID>/<AppName>.app
NSFileManager *manager = [NSFileManager defaultManager];
NSDictionary* attrs = [manager attributesOfItemAtPath:bundleRoot error:nil];
NSLog(@"Build or download Date/Time of first  version to be installed: %@", [attrs fileCreationDate]);
NSLog(@"Date/Time of last install (unless bundle changed by code): %@", [attrs fileModificationDate]);
NSString *rootPath = [bundleRoot substringToIndex:[bundleRoot rangeOfString:@"/" options:NSBackwardsSearch].location]; // e.g /var/mobile/Applications/<GUID>
attrs = [manager attributesOfItemAtPath:rootPath error:nil];
NSLog(@"Date/Time first installed (or first reinstalled after deletion): %@", [attrs fileCreationDate]);
like image 103
Andy Bradbrook Avatar answered Nov 09 '22 03:11

Andy Bradbrook


You could save a version number to NSUserDefaults, and update it accordingly.

If that won't work, you may be able to release an intermediate version which introduces the versioning scheme.

If that's not an option, you may be able to check for traces of previous runs from files you create, or preferences which you set conditionally or lazily.

like image 32
justin Avatar answered Nov 09 '22 02:11

justin