Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect an iOS App installed or upgraded? [duplicate]

Tags:

I am developing an application and i need to know whether user installed the app for the first time or upgraded it from the App Store.

How can i detect whether app is installed for the first time or upgraded or re-installed?

Thanks for your answers in advance.

like image 971
Hamza Öztürk Avatar asked Mar 01 '14 19:03

Hamza Öztürk


People also ask

How do I know if my iOS app is 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 if an app is installed iOS?

In the older software, there is no way of finding out exactly when an app was purchased, but in the latest software, you can go to the App Store and select Updates, then click on the top right to go to Purchased and see if the app was purchased (paid or free) and the date of install.

Can you install the same app twice iPhone?

You can place multiple copies of the same app on your home screen with iOS 15. Here's a funny one: iOS 15 lets you place multiple copies of the same app on Springboard. This means you can have the same app duplicated across your home screens, as many times as you want.


2 Answers

You can differentiate between the first start after installing the App, the first start after an update and other starts quite easily via saving the latest known version to standardUserDefaults. But as far as I know it is not possible do detect a re-install of the App as all App-related data are also removed when the App is deleted from the device.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {     NSString* currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];     NSString* versionOfLastRun = [[NSUserDefaults standardUserDefaults] objectForKey:@"VersionOfLastRun"];      if (versionOfLastRun == nil) {         // First start after installing the app     } else if (![versionOfLastRun isEqual:currentVersion]) {         // App was updated since last run     } else {         // nothing changed      }      [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:@"VersionOfLastRun"];     [[NSUserDefaults standardUserDefaults] synchronize]; } 
like image 175
Nero Avatar answered Sep 29 '22 18:09

Nero


Checkout Swift 3.0 version of code.
Note: Use CFBundleShortVersionString, for checking actual App version checking.

func checkAppUpgrade() {     let currentVersion = Bundle.main.object(forInfoDictionaryKey:     "CFBundleShortVersionString") as? String     let versionOfLastRun = UserDefaults.standard.object(forKey: "VersionOfLastRun") as? String      if versionOfLastRun == nil {         // First start after installing the app      } else if versionOfLastRun != currentVersion {         // App was updated since last run      } else {         // nothing changed      }      UserDefaults.standard.set(currentVersion, forKey: "VersionOfLastRun")     UserDefaults.standard.synchronize() } 
like image 36
Saggy Avatar answered Sep 29 '22 17:09

Saggy