Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Documentation for app update notification

Is there any documentation saying that when the application on Appstore is updated a push notification is send by Appstore itself to user about the update ?

like image 313
Prerna chavan Avatar asked Jan 17 '23 05:01

Prerna chavan


1 Answers

You can do that with Search API. In your app , after launching , check to see what is the latest version of your app on the AppStore. Like this:

- (void) checkForUpdates
{
    NSString *jsonUrl = @"http://itunes.apple.com/search?term=yourAppName&entity=software&limit=1";
    NSData *jsonData = [NSData dataWithContentsOfURL:[NSURL URLWithString:jsonUrl]];

    JSONDecoder *jsonKitDecoder = [JSONDecoder decoderWithParseOptions:JKParseOptionNone];
    NSObject *jsonObject = [jsonKitDecoder objectWithData:jsonData error:nil];
    int results = [[jsonObject valueForKey:@"resultCount"] intValue];

    if(results >0) // has results
    { 
        NSArray *results = [jsonObject valueForKey:@"results"];
        for(NSObject *aResult in results) 
        {
            NSString    *appStoreVersion = [aResult valueForKey:@"version"];
            NSString    *localVersion    = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];

            if(![appStoreVersion isEqualToString:localVersion])
            {
                 //there is an update available. Go crazy.
            }
        }
     }
}

I used JSONKit for this.. you can use any library that you like to parse the JSON retrieved by Apple.

Note: You can use this to notify the user that there is an update WHEN he opens the app. If you want something that tells the user as soon as the update is live , you need push notifications.

Hope this helps.

Cheers!

like image 85
George Avatar answered Jan 30 '23 22:01

George