How to detect the first launch of the application after updating from the application store, iphone

I need to do something only after updating the application from the AppStore. I do this using NSUserDefaults, but this is not good for me because it only works after the first update.

help

thanks

+4
source share
3 answers

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

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

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

-2
source

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

Manages blocks of code that need to be executed only once when upgrading the version in iOS applications. This can be anything from data normalization procedures, β€œWhat's New in This Release”, or bug fixes.

Usage example:

 [MTMigration migrateToVersion:@"0.9" block:^{ // Some 0.9 stuff }]; [MTMigration migrateToVersion:@"1.0" block:^{ // Some 1.0 stuff }]; 
+10
source
 if ([[NSString stringWithFormat:@"Version %@",[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]]isEqualToString:@"Version 1.0"]) { // run your code here } 
+1
source

All Articles