How to check if the app was already installed

Sergey92zp

I have an app that I want to make an update for it.

I have a list of items in application, but now I want to add versions for this items, so when item will be updated it will be marked as Updated. or if i will add a new item it will be marked like New.

But now for new users that install app first time all items should be new, and for users that already have app on their devices all items should be without any mark intially. I don't have any user defaults now in app so i can't check some value.

How can I check if app was already installed on device?

Rafa de King

The answer is that you cannot know it if you didn't store any information that would help you to check if the user is updating the app or installing it from scratch.

You can use this code to know it, starting from the version you would implement it in.

BOOL versionUpgraded;
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
NSString *previousVersion = [prefs stringForKey:@"appVersion"];

if ([[NSUserDefaults standardUserDefaults] stringForKey:@"appVersion"] != nil) 
{
    // See if version is the same as the previous one. If NOT, it is an Update.
    versionUpgraded = !([previousVersion isEqualToString: version]);
} 
// No "appVersion" means new install.
else 
{
    versionUpgraded = YES; 
}

if (versionUpgraded) 
{
    [[NSUserDefaults standardUserDefaults] setObject:version 
                                              forKey:@"appVersion"];
    [[NSUserDefaults standardUserDefaults] setObject:previousVersion        
                                              forKey:@"prevAppVersion"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

What you can also do is to check if there is any data you cache, store etc. Anything in NSUserDefaults, or any kind of database, or Documents folder, that would mean that the app was already installed.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to check if pyodbc is already installed on my MacOS?

From Dev

How to check if the MPI already installed on my machine

From Dev

How to detect if the Wear app of my Android app is already installed in the watch

From Dev

How can I check if a certain patch is already installed in my system?

From Dev

How to check if a module or a package is already installed in python3?

From Dev

How to check if a Firebase App is already initialized on Android

From Dev

How to check if a Firebase App is already initialized on Android

From Dev

How to check if calendar app installed in android?

From Dev

yum - check if package already installed

From Dev

yum - check if package already installed

From Dev

How do I know if an app is already installed on iPhone from Safari

From Dev

Android: How to know which contacts already have the app installed?

From Dev

How do I know if an app is already installed on iPhone from Safari

From Dev

Android: How to know which contacts already have the app installed?

From Dev

How to launch already installed app from iPhone using appium

From Dev

How to launch already installed iOS App on iPhone remotely?

From Dev

Check if paid app was installed

From Dev

How to check if a chrome app is installed in a different chrome app?

From Dev

Script to check if some program is already installed

From Dev

Script to check if some program is already installed

From Dev

iOS in app purchase. How to check if purchase already bought?

From Dev

How to check if an app has already been purchased - CodenameOne

From Dev

How to check if Tencent(Weibo) app is installed on Android or not programmatically?

From Dev

How to check if the app is preloaded or installed from Windows Phone marketplace

From Dev

How to check using jsp whether an app is installed in mobile or not?

From Dev

How can I check if the user has installed an app?

From Dev

iOS Data Protection not working on already installed app

From Dev

Using GoogleMaps app installed on the phone already

From Dev

Check if Android app is installed by playstore

Related Related

  1. 1

    How to check if pyodbc is already installed on my MacOS?

  2. 2

    How to check if the MPI already installed on my machine

  3. 3

    How to detect if the Wear app of my Android app is already installed in the watch

  4. 4

    How can I check if a certain patch is already installed in my system?

  5. 5

    How to check if a module or a package is already installed in python3?

  6. 6

    How to check if a Firebase App is already initialized on Android

  7. 7

    How to check if a Firebase App is already initialized on Android

  8. 8

    How to check if calendar app installed in android?

  9. 9

    yum - check if package already installed

  10. 10

    yum - check if package already installed

  11. 11

    How do I know if an app is already installed on iPhone from Safari

  12. 12

    Android: How to know which contacts already have the app installed?

  13. 13

    How do I know if an app is already installed on iPhone from Safari

  14. 14

    Android: How to know which contacts already have the app installed?

  15. 15

    How to launch already installed app from iPhone using appium

  16. 16

    How to launch already installed iOS App on iPhone remotely?

  17. 17

    Check if paid app was installed

  18. 18

    How to check if a chrome app is installed in a different chrome app?

  19. 19

    Script to check if some program is already installed

  20. 20

    Script to check if some program is already installed

  21. 21

    iOS in app purchase. How to check if purchase already bought?

  22. 22

    How to check if an app has already been purchased - CodenameOne

  23. 23

    How to check if Tencent(Weibo) app is installed on Android or not programmatically?

  24. 24

    How to check if the app is preloaded or installed from Windows Phone marketplace

  25. 25

    How to check using jsp whether an app is installed in mobile or not?

  26. 26

    How can I check if the user has installed an app?

  27. 27

    iOS Data Protection not working on already installed app

  28. 28

    Using GoogleMaps app installed on the phone already

  29. 29

    Check if Android app is installed by playstore

HotTag

Archive