Determine if you own app is currently installed or not programmatically

75 views Asked by At

I am creating a new feature in one of my apps to show a "What's New" page. I have this all working as expected and it compares the last version (stored) to the current version, then updates the current version once the feature list is shown.

This all works great and as expected. The issue I have now is determining if a user already has the app installed.

Case 1) If the user is a completely new user and it is the first time they have downloaded the app, then the new feature list should not be shown.

Case 2) If they already had the app installed and are updating their app to a new version, then we need to show the new feature list.

The part I need help with is Case 2. How can you determine if the app is already installed by the user, without having to release a minor update just to set a currentInstalledVersion variable beforehand?

2

There are 2 answers

6
Dima On BEST ANSWER
if(currentInstalledVersion)
{
   if(currentInstalledVersion < actualCurrentVersion)
   {
      // user upgraded
   }
}
else
{
   if(someOtherDataSavedOnDiskExists)
   {
      // user had the app with a version before you implemented currentInstalledVersion and is updating
   }
   else
   {
     // fresh install
   }
}

Update based on below comment

Okay in that case, there is no built-in mechanism to help you with this. Until you implement a way yourself (with this flag), you can't check. However, if you have any kind of other flags or data you've written to NSUserDefaults for instance, you can check that immediately on startup to see if those values are set which would tell you it is an existing user that just installed the app (only check the other flags if currentInstalledVersion is not set). If you have not written any data to disk or to NSUserDefaults then you are out of luck for your initial release of this feature.

I updated the code above to reflect this.

1
AdminXVII On

You could use NSUserDefault and set a bool to check if it's a new user. ex:

if(![[NSUserDefaults standardUserDefaults] boolForKey:@"user"]){
  // it's a new user
  [[NSUserDefaults standardUserDefaults] setBool:YES ForKey:@"user"];
}

The boolForKey: method would return NO if the default was not set.