Guy Kahlon
Guy Kahlon

Reputation: 4520

how to detect first time app launch after update from app store ,iphone

I need to do something only after when the application update from appstore. I do it with NSUserDefaults but it's not good for me because it works only after the first update.

help

thanks

Upvotes: 4

Views: 2937

Answers (3)

KennyVB
KennyVB

Reputation: 755

if ([[NSString stringWithFormat:@"Version %@",[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]]isEqualToString:@"Version 1.0"])
{
// run your code here
}

Upvotes: 1

Mike Weller
Mike Weller

Reputation: 45598

The MTMigration project (MIT license) does exactly what you want:

Manages blocks of code that only need to run once on version updates in iOS apps. This could be anything from data normalization routines, "What's New In This Version" screens, or bug fixes.

An example of its use:

[MTMigration migrateToVersion:@"0.9" block:^{
    // Some 0.9 stuff
}];

[MTMigration migrateToVersion:@"1.0" block:^{
    // Some 1.0 stuff
}];

Upvotes: 10

Mutawe
Mutawe

Reputation: 6524

You can compare the current version with the old version as follow:

[NSString stringWithFormat:@"Version %@",[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]];

And with an if statement for the current version that you know it 1.1, 2.0 .... etc, you can handle it.

Upvotes: -2

Related Questions