Search code examples
iphoneobjective-capp-storeversionitunes

Can we Obtain Version Number of application from App Store for iPhone?


Instead of using a web-service to get current application version number and comparing it in my code for popping up update alert, Is there any way to obtain the application version number from App-Store / i-Tunes directly?

After going through all the comments correct me if i am wrong.

  1. We should not show a Local Notification(as alert) to User regarding availability of new update programatically?

I went though HIG Guidelines, but could not fing such creteria. So little confused in deciding.


Solution

  • Alert updates like this will certainly be against Apple guidelines. For iOS devices, application alerts are displayed by the App store app with a badge displaying the number of updates available. There is nothing a developer needs to do.

    If you are worried about the user missing your app update, rest assured that iOS users keep an eye on the app-store app & know that all updates come through it.

    However, there are hacky ways by which you can figure out that this is your first run after an update without contacting any web service or iTunes/App store.

    One of the hacks known to me:

    Fetch the library directory path-

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
    NSString *libPath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
    

    libPath would be something like - /var/mobile/Applications/8CFB747F-9446-44CB-98B9-C6FF1CF7BF93/Library

    This random string before /Library changes with every update. You can save this string in NSUserDefaults, and compare the path with the saved string on every launch. If the strings are found to be different, it implies that this is your first run after the update. Display the update alert! Then update the saved string with the new one.