0

I am trying to notify user, if newer version of my app available on app store.So i used below URL to validate current version and existing version of my app

http://itunes.apple.com/lookup?id=APPLEID

I got repose like this

{
 "resultCount":0,
 "results": []
}

Sometimes i am getting proper repose,But sometime not.Is there any alternative to achieve this feature in iOS app

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Balaji
  • 372
  • 1
  • 4
  • 18
  • 1
    see this http://stackoverflow.com/questions/6256748/check-if-my-app-has-a-new-version-on-appstore – Anbu.Karthik Mar 01 '17 at 10:36
  • https://github.com/nicklockwood/iVersion or you can use this update Manager https://gist.github.com/fahadjamal/c6ee03e790c1b3c22d4f04fc5a09ccb0 – Fahad Jamal Mar 01 '17 at 10:40

2 Answers2

1

Use Harpy library to get update when new version available to download.

Find sample project , usage and installation in github link

Link for download harpy library

You can get it by Cocoapods or adding files to your project

Himanth
  • 2,381
  • 3
  • 28
  • 41
  • Let me try this library – Balaji Mar 01 '17 at 10:46
  • Let me know the status after implemented – Himanth Mar 01 '17 at 10:52
  • This also not working,I am getting like this [Harpy]: storeURL: https://itunes.apple.com/lookup?bundleId=com.app.appname 2017-03-01 17:40:17.737808 appname[2798:957080] [Harpy]: JSON Results: { resultCount = 0; results = ( ); } – Balaji Mar 01 '17 at 12:14
0

Instead of checking app id you can compare bundleId to notify user new version available to download.

You can try this :

-(void) checkForNewVersion{

    NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];

    NSString* appID = infoDictionary[@"CFBundleIdentifier"];

    NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?bundleId=%@", appID]];

    NSData* data = [NSData dataWithContentsOfURL:url];

    if(data != nil)
    {

        NSDictionary* lookup = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];

        if ([lookup[@"resultCount"] integerValue] == 1){

            NSString* appStoreVersion = lookup[@"results"][0][@"version"];

            NSString* currentVersion = infoDictionary[@"CFBundleShortVersionString"];

            if ([appStoreVersion compare:currentVersion options:NSNumericSearch] == NSOrderedDescending) {
                // Alert View

            }

        }
    }
}
Sid Mhatre
  • 3,272
  • 1
  • 19
  • 38
  • already i tried this method,But sometimes i am not getting value using this URL http://itunes.apple.com/lookup?bundleId=AppleID – Balaji Mar 01 '17 at 10:57
  • You can use` Harpy` : this module trigger a UIAlertView when a new version of your app is available on the App Store. – Sid Mhatre Mar 01 '17 at 11:03
  • Harpy also not working,I am getting like this [Harpy]: storeURL: https://itunes.apple.com/lookup?bundleId=com.app.appname 2017-03-01 17:40:17.737808 appname[2798:957080] [Harpy]: JSON Results: { resultCount = 0; results = ( ); } – Balaji Mar 01 '17 at 12:16