2011-09-11 35 views

回答

14

您需要在您的服務器(或類似的東西),你的應用程序要求在啓動時,知道哪些是可用的最新版本上一個WebService。 (如果您沒有WS但真的不希望實現一個,你也可以簡單地使用包含版本的XML或文本文件太)

然後比較這版本從您的服務器中檢索與當前版本的應用程序一起使用,使用[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]

如果它們是不同的,則可以顯示alertview並重定向到itms-apps://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftwareUpdate?id=[APPID]&mt=8,這是會讓你的iPhone直接打開AppStore的應用程序應用程序的更新頁面上的鏈接(你iTunes Connect的應用程序ID更換APPID

+2

對此的改進將發送一個用戶通知請求到您的服務器。此請求將包括設備類型,應用程序版本,iOS版本以及各種其他診斷信息。然後,您的服務器可以根據該信息決定將哪些消息發送給應用程序。例如,如果您發現僅影響某些設備的重大錯誤,則可以讓受影響的用戶知道您已向Apple提交錯誤修復。 – Jim

+5

請注意,由於此答案,Apple確實發佈了[iTunes Search API](http://www.apple.com/itunes/affiliates/resources/documentation/itunes-afforeates/resources-search-api.html),所以你可以調用'http://itunes.apple.com/lookup?id= '得到一個包含你的應用的一些元數據的JSON,包括它在商店中的版本。您可以將它與Info.plist中的版本('CFBundleVersion')進行比較,並在它們不同時觸發警報。您甚至可以使用'SKStoreProductViewController'在直接集成到您的應用中的AppStore中呈現您的應用的頁面。 – AliSoftware

-2

我的一個朋友剛剛推出的一項服務,CleverStork,但這幾乎正是你想要的。

我沒有用它自己,但我的理解是,它會提示用戶 - 通過應用程序內的警報 - 下載你的應用程序的新版本。他們提供免費和付費計劃。

+0

您提供的產品鏈接已死亡。 – shrishaster

12

要檢查,看看是否有最新的版本只是用下面的查詢查詢的iTunes應用程序數據(注:更改ID,匹配來自iTunesConnect您的應用程序的ID):

這將返回一個JSON字典很容易轉換爲NSDictionary以便直接在您的代碼中使用,那麼您只需提取「版本」鍵的值並將其與您的應用程序版本號進行比較(請參閱版本鍵/值下面以粗體顯示):

{ 
    "resultCount": 1, 
    "results": [ 
     { 
      "kind": "software", 
      "features": [], 
      "supportedDevices": [ 
       "all" 
      ], 
      "isGameCenterEnabled": false, 
      "artistViewUrl": "https://itunes.apple.com/us/artist/d-m-holdings/id388608883?uo=4", 
      "artworkUrl60": "http://a899.phobos.apple.com/us/r1000/086/Purple/v4/6d/b3/05/6db305aa-c685-558b-8c8e-8b7245375ce1/IconAudio.png", 
      "screenshotUrls": [ 
       "http://a86.phobos.apple.com/us/r1000/078/Purple/v4/8f/ff/47/8fff4783-f2e4-fe3f-ef92-96d67d66c12b/mzl.dwbdvxny.png", 
       "http://a731.phobos.apple.com/us/r1000/097/Purple/v4/cb/65/f6/cb65f613-408a-dffe-fb36-165db0c1a360/mzl.jexyhdnq.png", 
       "http://a940.phobos.apple.com/us/r1000/097/Purple/v4/f6/26/a1/f626a18c-691f-7345-8d3d-f19713144818/mzl.llsgsagl.png", 
       "http://a185.phobos.apple.com/us/r1000/071/Purple/v4/7d/5e/bc/7d5ebcad-7755-e772-727c-65de99effd60/mzl.zuyvhebk.png", 
       "http://a48.phobos.apple.com/us/r1000/096/Purple/v4/d6/f5/f1/d6f5f108-10ab-3738-26cf-5ce82c6bb690/mzl.ijtyynie.png" 
      ], 
      "ipadScreenshotUrls": [], 
      "artworkUrl512": "http://a672.phobos.apple.com/us/r1000/100/Purple/v4/e3/cb/5d/e3cb5d2d-f1a8-8b80-3a91-58be8f654710/mzm.uogqezwx.png", 
      "artistId": 388608883, 
      "artistName": "D&M Holdings", 
      "price": 0, 
      **"version": "1.0.5",** 
      "description": "Designed to enhance the listening experience with Denon’s new line of Music Maniac™ headphones, the Denon Audio app is designed for the on-the-go audiophile. The Denon Audio app features a premium audio player that lets you experience the best possible sound quality from your iPod music library and favorite Internet radio stations. Create & save custom EQ curves, create & save instant playlists, enjoy internet radio stations via the built-in TuneIn service, and more. The Denon Audio app will quickly replace all of your other music apps.\n \nThe Denon Audio app features a customizable graphical equalizer that lets you contour your own sound by directly manipulating more than 1000 discrete bands of equalization without adding spatial distortion or decreasing sound quality. Pump up the bass, restore those highs, and start jammin’! \n \nEQ FEATURES:\n \n• Graphical equalizer for your iPod music library and streaming Internet Radio\n• 1000 possible discrete bands\n• 10 built in EQ Presets\n• Create and save your own EQ Presets\n• Bypass mode to quickly compare the original and equalized audio\n• Real-time spectrum analyzer\n• Linear phase design\n• No spatial distortion\n\nIPOD MUSIC LIBRARY FEATURES:\n\n• Enhances your listening experience with Denon Music Maniac Headphones or other audio playback devices such as docking stations, a/v receivers, car stereos via USB, Bluetooth, or Airplay.\n• Powerful queue based playback system lets you build and order your own playlist on the fly.\n• Save the playback queue as a new playlist\n• A single song, all songs on an album, all songs by an artist, and all songs in a genre can easily be added to the now playing queue.\n• Supports both portrait and landscape modes for browsing, playing, and equalizing\n• Shuffle and repeat playback modes\n• iPod library browsing by Playlist, Artist, Album, Song, Genre, Composer, Compilation, and Podcast (no importing needed)\n\nINTERNET RADIO FEATURES:\n\n• The TuneIn service provides global access to Internet radio – covering over 70,000 radio stations and 2 million on-demand programs including sports, news, talk, music and comedy. \n• Browse Internet radio stations by location, genre, language or Podcast (on-demand programs).\n• Powerful search feature for your iPod music library and Internet Radio \n• Save your favorite Internet Radio stations or programs as convenient presets and share them with other TuneIn compatible devices\n• Ability to choose high or low quality streams offered by broadcasters\n \nADDITIONAL FEATURES:\n\n• Streams music over AirPlay to any Denon AirPlay compatible receiver or HiFi product\n• Share what you’re listening to via Facebook, Twitter, Email, or Text Message (iMessage)\n\nNOTICES:\n \n• The Denon Audio app requires iOS 5 or later and works with the iPhone 3GS or newer, the iTouch 3rd generation or newer, and all iPads (in 2x mode). \n• DRM protected iTunes music is NOT supported by the Denon Audio app (or any 3rd party music app)\n• iTunes Match will be supported in a future update \n• WiFi or data connection required to stream Internet radio", 
      "currency": "USD", 
      "genres": [ 
       "Music", 
       "Lifestyle" 
      ], 
      "genreIds": [ 
       "6011", 
       "6012" 
      ], 
      "releaseDate": "2012-05-29T07:00:00Z", 
      "sellerName": "D&M Holdings Inc.", 
      "bundleId": "com.dm-holdings.denon-audio", 
      "trackId": 520604518, 
      "trackName": "Denon Audio", 
      "primaryGenreName": "Music", 
      "primaryGenreId": 6011, 
      "releaseNotes": "• Added 4\" display support for the iPhone 5 and 5th generation iPod Touch\n\n• Added an audio limiter function to protect against possible distortion introduced from pushing the EQ too high\n\n• Displays the Shuffle, Repeat, AirPlay, and Share icons as well as the scan/scrub controls on the \"Now Playing\" screen by default (so everyone knows they are included in the app). Tap the cover art to hide/show these controls", 
      "formattedPrice": "Free", 
      "wrapperType": "software", 
      "trackCensoredName": "Denon Audio", 
      "trackViewUrl": "https://itunes.apple.com/us/app/denon-audio/id520604518?mt=8&uo=4", 
      "contentAdvisoryRating": "4+", 
      "artworkUrl100": "http://a672.phobos.apple.com/us/r1000/100/Purple/v4/e3/cb/5d/e3cb5d2d-f1a8-8b80-3a91-58be8f654710/mzm.uogqezwx.png", 
      "languageCodesISO2A": [ 
       "ZH", 
       "DE", 
       "EN", 
       "ES", 
       "FR", 
       "JA", 
       "NL" 
      ], 
      "fileSizeBytes": "9060882", 
      "sellerUrl": "http://www.usa.denon.com/headphones", 
      "averageUserRatingForCurrentVersion": 4.5, 
      "userRatingCountForCurrentVersion": 329, 
      "trackContentRating": "4+", 
      "averageUserRating": 4.5, 
      "userRatingCount": 471 
     } 
    ] 
} 

以下是完成此任務的一些代碼。 -rrh

NSURL *url = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@",APPSTORE_ID]]; 
NSURLRequest *request = [NSURLRequest requestWithURL:url]; 

[NSURLConnection sendAsynchronousRequest:request 
            queue:[NSOperationQueue mainQueue] 
         completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { 
          if (!error) { 
           NSError* parseError; 
           NSDictionary *appMetadataDictionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&parseError]; 
           NSArray *resultsArray = (appMetadataDictionary)?[appMetadataDictionary objectForKey:@"results"]:nil; 
           NSDictionary *resultsDic = [resultsArray firstObject]; 
           if (resultsDic) { 
            // compare version with your apps local version 
            NSString *iTunesVersion = [resultsDic objectForKey:@"version"]; 

            NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)@"CFBundleShortVersionString"]; 
            if (iTunesVersion && [appVersion compare:iTunesVersion] != NSOrderedSame) { // new version exists 
             // inform user new version exists, give option that links to the app store to update your app - see AliSoftware's answer for the app update link 
             UIAlertView *alert = [UIAlertView bk_showAlertViewWithTitle:APP_NAME message:[NSString stringWithFormat:@"New version %@ available. Update required.",iTunesVersion] cancelButtonTitle:@"update" otherButtonTitles:nil handler:^(UIAlertView *alertView, NSInteger buttonIndex) { 


             NSString *iTunesLink = [NSString stringWithFormat:@"itms://itunes.apple.com/us/app/apple-store/id%@?mt=8",APPSTORE_ID]; 
             [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]]; 
             }]; 
             [alert show]; 
            } 
           } 
          } else { 
           // error occurred with http(s) request 
           NSLog(@"error occurred communicating with iTunes"); 
          } 
         }]; 
+0

但根據應用商店審查指南「從蘋果網站刮取任何信息的應用程序(例如,來自apple.com,iTunes Store,App Store,iTunes Connect,Apple Developer Programs等的應用程序)或創建使用來自蘋果網站和服務的內容的排名將被拒絕「 –

+0

所以它會從應用程序? –

+0

使用iTMS Web服務不是我稱之爲」廢棄「(通常意思是」從內容中提取數據不是設計用於解析「就像從HTML中的網頁中提取信息一樣),這是一個Web服務,根據定義,爲了讓開發人員獲得並解析該信息(以及它的文檔和所有內容),只要你不'如果你甚至只用它來查詢關於你自己的應用程序而不是其他的信息,似乎很難將其限定爲服務的過度使用 – AliSoftware

相關問題