Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Application Update Test

Tags:

ios

Is there a method though it wants to test when the application is updated?

I am embarrassed because there is a bug that occurs only when the application is updated, and it doesn't investigate.

like image 259
user375364 Avatar asked Jul 21 '11 06:07

user375364


1 Answers

If you are asking if you want to find when the application is updated through app store, I am not aware of such a method.

A hackie approach to do this is to save the current app version to NSUserDefaults, then check if the NSUserDefaults app version is equal to the current app version.

For example:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    NSString *currentAppVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];

    if ([defaults objectForKey:@"savedAppVersionKey"] != nil) {
        //key exists

        NSString *savedAppVersion = [[NSUserDefaults standardUserDefaults] objectForKey:@"savedAppVersionKey"];

        if ([currentAppVersion isEqualToString:savedAppVersion]) {
            //still running the same app version
        }
        else {
            //the app version changed from the last launch
        }

    }
    else {
        //first run, set the key & synchronize
        [[NSUserDefaults standardUserDefaults] setObject:currentAppVersion forKey:@"savedAppVersionKey"];

        [[NSUserDefaults standardUserDefaults] synchronize] 
    }

}

I haven't tested the code, but it should work.

Thanks,

-David

like image 191
bobbypage Avatar answered Sep 28 '22 17:09

bobbypage