首页 > 其他分享 >iOS应用检查更新的最优方法

iOS应用检查更新的最优方法

时间:2023-04-30 18:33:15浏览次数:33  
标签:http mzstatic iOS 更新 u2022 us 最优 com your


虽然App Store能够提醒用户软件更新,但很多用户不会主动去更新一大堆的软件(我机器上待更新的软件在100个左右)。如果在软件开启时提醒用户更新 或者 更多中设置“检查更新”项,效果会好很多。


    1. NSString *version = @"";  
    2. NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/lookup?id=<</span>Your app ID>"];  
    3. versionRequest = [ASIFormDataRequest requestWithURL:url];  
    4. setRequestMethod:@"GET"];  
    5. setDelegate:self];  
    6. setTimeOutSeconds:150];  
    7. addRequestHeader:@"Content-Type" value:@"application/json"];   
    8. startSynchronous];  
    9.  
    10. string of our REST call  
    11. NSString* jsonResponseString = [versionRequest responseString];  
    12.  
    13. NSDictionary *loginAuthenticationResponse = [jsonResponseString objectFromJSONString];  
    14.  
    15. NSArray *configData = [loginAuthenticationResponse valueForKey:@"results"];  
    16.  
    17. (id config in configData)   
    18. {  
    19.    version = [config valueForKey:@"version"];  
    20. }  
    21. your version with the version in app store  
    22. (![version isEqualToString:[itsUserDefaults objectForKey:@"version"]])   
    23. {  
    24.    ProAlertView *createUserResponseAlert = [[ProAlertView alloc] initWithTitle:@"New Version!!" message: @"A new version of app is available to download" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles: @"Download", nil];  
    25. show];   
    26. release];  
    27. }




    1. (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {  
    2.    // the user clicked one of the OK/Cancel buttons  
    3.    if (buttonIndex == 1)  
    4.    {  
    5.        NSString *iTunesLink = @"itms-apps://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftwareUpdate?id=<</span>appid>&mt=8";  
    6.        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];  
    7.    }  
    8. }




    以Remote (http://itunes.apple.com/app/remote/id284417350?mt=8) 软件为例,请求http://itunes.apple.com/lookup?id=284417350返回的数据为:


    1. {  
    2. "resultCount":1,  
    3. "results": [  
    4. "features":["iosUniversal"], "supportedDevices":["all"], "isGameCenterEnabled":false,   
    5. "http://a3.mzstatic.com/us/r1000/119/Purple/63/7f/c2/mzl.qybzxzxq.png", "http://a1.mzstatic.com/us/r1000/092/Purple/16/8a/13/mzl.fywgpbnb.png", "http://a2.mzstatic.com/us/r1000/103/Purple/b3/90/2e/mzl.xlpzzirl.png", "http://a4.mzstatic.com/us/r1000/069/Purple/f4/07/0b/mzl.cynatymj.png"],   
    6. "http://a4.mzstatic.com/us/r1000/084/Purple/v4/7a/f7/78/7af778c9-1546-ddeb-b5de-b577b703e28c/mza_8776755316162530832.1024x1024-65.jpg", "http://a2.mzstatic.com/us/r1000/111/Purple/v4/8e/49/7b/8e497b65-923d-715e-42b3-1b671841ee7d/mza_3991863266621328291.1024x1024-65.jpg", "http://a3.mzstatic.com/us/r1000/063/Purple/v4/6a/d4/f3/6ad4f3e4-7e73-be6e-f585-37eb65b0f812/mza_7049654211100682802.1024x1024-65.jpg", "http://a2.mzstatic.com/us/r1000/118/Purple/v4/d9/79/6f/d9796f55-a73a-f570-c20a-3594d5a49bdc/mza_6340688527152336903.1024x1024-65.jpg"], "artworkUrl60":"http://a3.mzstatic.com/us/r1000/069/Purple/a8/e3/35/mzi.swfjtgvw.png", "artworkUrl512":"http://a4.mzstatic.com/us/r1000/061/Purple/2c/a0/b7/mzl.lusstdyg.png", "artistViewUrl":"http://itunes.apple.com/us/artist/apple/id284417353?mt=12&uo=4", "artistId":284417353, "artistName":"Apple", "price":0.00, <</span>SPAN style="COLOR: rgb(255,0,0)">"version":"2.3"</</span>SPAN>,   
    7. iTunes and Apple TV using your iPhone, iPad, or iPod touch over your Wi-Fi network. Choose playlists, songs, and albums as if you were in front of your computer or Apple TV. Or play them from iCloud with iTunes Match on Apple TV. From anywhere in your home, you can change a song, pick a playlist, or browse your entire library. With a flick of your finger, you can control the Apple TV interface. Use your iOS device's keyboard to quickly tap out a title instead of clicking letters on the Apple TV screen. Then keep tapping to play, fast-forward, rewind, and pause to your finger\u2019s content. Remote is fully optimized for the stunning Retina display in iPhone, iPad, and iPod touch and is designed to take advantage of the large Multi-Touch display on iPad. \n\nFeatures\n\u2022 Control iTunes and Apple TV from anywhere in your home\n\u2022 Browse, listen to, and control your iTunes Match library on Apple TV\n\u2022 Pause, rewind, fast-forward, shuffle, and adjust the volume from your iPhone, iPad, or iPod touch\n\u2022 View album, movie, and TV show artwork\n\u2022 Create and update iTunes playlists, including Genius playlists\n\u2022 Search your entire iTunes library\n\u2022 Control iTunes to send music to AirPlay speakers\n\u2022 Control the volume on each speaker independently\n\u2022 Use simple gestures to control Apple TV\n\u2022 Enter text with the keyboard\n\u2022 Control shared libraries on iTunes and the new Apple TV", "genreIds":["6016", "6011"], "releaseDate":"2008-07-11T07:00:00Z", "sellerName":"Apple Inc.", "currency":"USD", "genres":["Entertainment", "Music"], "bundleId":"com.apple.Remote", "trackId":284417350, "trackName":"Remote", "primaryGenreName":"Entertainment", "primaryGenreId":6016, "releaseNotes":"\u2022 Support for iTunes Match on Apple TV\n\u2022 Support for Retina display on iPad", "wrapperType":"software", "trackCensoredName":"Remote",   
    8. "CA", "CS", "DA", "DE", "EL", "EN", "ES", "FI", "FR", "HR", "HU", "ID", "IT", "HE", "JA", "KO", "MS", "NL", "NO", "PL", "PT", "RO", "RU", "SK", "SV", "TH", "TR", "UK", "VI", "ZH"], "fileSizeBytes":"21992445", "sellerUrl":"http://www.apple.com/itunes/remote", "contentAdvisoryRating":"4+", "averageUserRatingForCurrentVersion":3.5, "userRatingCountForCurrentVersion":794, "artworkUrl100":"http://a4.mzstatic.com/us/r1000/061/Purple/2c/a0/b7/mzl.lusstdyg.png", "trackViewUrl":"http://itunes.apple.com/us/app/remote/id284417350?mt=8&uo=4", "trackContentRating":"4+", "averageUserRating":3.5, "userRatingCount":197847}]  
    9. }  
     
     
    {
     "resultCount":1,
     "results": [
    {"kind":"software", "features":["iosUniversal"], "supportedDevices":["all"], "isGameCenterEnabled":false, 
    "screenshotUrls":["http://a2.mzstatic.com/us/r1000/113/Purple/99/f8/ea/mzl.dcxkisqn.png", "http://a3.mzstatic.com/us/r1000/119/Purple/63/7f/c2/mzl.qybzxzxq.png", "http://a1.mzstatic.com/us/r1000/092/Purple/16/8a/13/mzl.fywgpbnb.png", "http://a2.mzstatic.com/us/r1000/103/Purple/b3/90/2e/mzl.xlpzzirl.png", "http://a4.mzstatic.com/us/r1000/069/Purple/f4/07/0b/mzl.cynatymj.png"], 
    "ipadScreenshotUrls":["http://a2.mzstatic.com/us/r1000/114/Purple/v4/9e/9e/fd/9e9efd78-7a57-89dc-9c13-e0a3c01af95b/mza_382609288154297810.1024x1024-65.jpg", "http://a4.mzstatic.com/us/r1000/084/Purple/v4/7a/f7/78/7af778c9-1546-ddeb-b5de-b577b703e28c/mza_8776755316162530832.1024x1024-65.jpg", "http://a2.mzstatic.com/us/r1000/111/Purple/v4/8e/49/7b/8e497b65-923d-715e-42b3-1b671841ee7d/mza_3991863266621328291.1024x1024-65.jpg", "http://a3.mzstatic.com/us/r1000/063/Purple/v4/6a/d4/f3/6ad4f3e4-7e73-be6e-f585-37eb65b0f812/mza_7049654211100682802.1024x1024-65.jpg", "http://a2.mzstatic.com/us/r1000/118/Purple/v4/d9/79/6f/d9796f55-a73a-f570-c20a-3594d5a49bdc/mza_6340688527152336903.1024x1024-65.jpg"], "artworkUrl60":"http://a3.mzstatic.com/us/r1000/069/Purple/a8/e3/35/mzi.swfjtgvw.png", "artworkUrl512":"http://a4.mzstatic.com/us/r1000/061/Purple/2c/a0/b7/mzl.lusstdyg.png", "artistViewUrl":"http://itunes.apple.com/us/artist/apple/id284417353?mt=12&uo=4", "artistId":284417353, "artistName":"Apple", "price":0.00, "version":"2.3", 
    "description":"Control iTunes and Apple TV using your iPhone, iPad, or iPod touch over your Wi-Fi network. Choose playlists, songs, and albums as if you were in front of your computer or Apple TV. Or play them from iCloud with iTunes Match on Apple TV. From anywhere in your home, you can change a song, pick a playlist, or browse your entire library. With a flick of your finger, you can control the Apple TV interface. Use your iOS device's keyboard to quickly tap out a title instead of clicking letters on the Apple TV screen. Then keep tapping to play, fast-forward, rewind, and pause to your finger\u2019s content. Remote is fully optimized for the stunning Retina display in iPhone, iPad, and iPod touch and is designed to take advantage of the large Multi-Touch display on iPad. \n\nFeatures\n\u2022 Control iTunes and Apple TV from anywhere in your home\n\u2022 Browse, listen to, and control your iTunes Match library on Apple TV\n\u2022 Pause, rewind, fast-forward, shuffle, and adjust the volume from your iPhone, iPad, or iPod touch\n\u2022 View album, movie, and TV show artwork\n\u2022 Create and update iTunes playlists, including Genius playlists\n\u2022 Search your entire iTunes library\n\u2022 Control iTunes to send music to AirPlay speakers\n\u2022 Control the volume on each speaker independently\n\u2022 Use simple gestures to control Apple TV\n\u2022 Enter text with the keyboard\n\u2022 Control shared libraries on iTunes and the new Apple TV", "genreIds":["6016", "6011"], "releaseDate":"2008-07-11T07:00:00Z", "sellerName":"Apple Inc.", "currency":"USD", "genres":["Entertainment", "Music"], "bundleId":"com.apple.Remote", "trackId":284417350, "trackName":"Remote", "primaryGenreName":"Entertainment", "primaryGenreId":6016, "releaseNotes":"\u2022 Support for iTunes Match on Apple TV\n\u2022 Support for Retina display on iPad", "wrapperType":"software", "trackCensoredName":"Remote", 
    "languageCodesISO2A":["AR", "CA", "CS", "DA", "DE", "EL", "EN", "ES", "FI", "FR", "HR", "HU", "ID", "IT", "HE", "JA", "KO", "MS", "NL", "NO", "PL", "PT", "RO", "RU", "SK", "SV", "TH", "TR", "UK", "VI", "ZH"], "fileSizeBytes":"21992445", "sellerUrl":"http://www.apple.com/itunes/remote", "contentAdvisoryRating":"4+", "averageUserRatingForCurrentVersion":3.5, "userRatingCountForCurrentVersion":794, "artworkUrl100":"http://a4.mzstatic.com/us/r1000/061/Purple/2c/a0/b7/mzl.lusstdyg.png", "trackViewUrl":"http://itunes.apple.com/us/app/remote/id284417350?mt=8&uo=4", "trackContentRating":"4+", "averageUserRating":3.5, "userRatingCount":197847}]
    }


    请求出的version为2.3, 与本地客户端版本号比较,即可判断有无更新。

    标签:http,mzstatic,iOS,更新,u2022,us,最优,com,your
    From: https://blog.51cto.com/u_548275/6238008

    相关文章

    • IOS 小技巧积累
      1.使用@property和@synthesize声明一个成员变量,给其赋值是时要在前面加上"self.",以便调用成员变量的setmember方法。   直接调用成员变量并且给其赋值:member=[NSStringstringWithFormat:@””];将不执行setmember方法。  使用self调用成员变量并且给其赋值:self.member=......
    • Linux实用命令(持续更新)
      查看Linux是否为虚拟机方法1:systemd-detect-virt如果是vmware则为vmware的虚拟机,为none则不是虚拟机(是物理机)方法2:dmesg|grep-i"Hypervisordetected"方法3:lscpu|grep"Hypervisorvendor"方法4:dmidecode|grep"ProductName"如果是虚拟机则显示VMwareVirtualPlatf......
    • 如何彻底关闭 Windows 10 自动更新
      彻底关闭Windows10自动更新,分为三步,具体如下:1.组策略禁用Windows更新Win键+R,输入gpedit.msc,启动组策略编辑器。左侧选择[本地计算机配置]->[管理模板]->[Windows组件]->[Windows更新],禁用右侧的[配置自动更新]和[启用通过自动更新建议的更新]选项。2.停......
    • Linux用ntpdate自动同步时间后使用crontab定时任务更新
       两种同步linux系统的时间方法:(1)开启ntpd服务,即配置ntp服务器实现时间同步。(2)利用ntp客户端程序,即ntpdate同步时间。注意:因为ntp服务器本来就会与上层时间服务器进行同步,所以在默认的情况下,ntp服务器不可以使用ntpdate,也就是说ntpdate和ntpd不能同时启用。上一篇已经介绍......
    • iOS百度地图 定位的实现
      今天发现自己好笨啊。。。一直在搞定位,想为什么会是空的,原来定位也是需要代理去实现的在初始化地图的时候,也就是在viewDidload里面是这样的mapView.showsUserLocation=YES;if(mapView.userLocation.location!=nil){NSLog(@"定位成功");coor=......
    • IOS为每个网请求添加进度标示
      UIViewController的子类,且只有界面才有必要现实进度标示。然后在网络请求的开始和结束调用这个方法1.基于UIViewController做扩展#import@implementationvoid)showProgress{NSLog(@"=======showProgress=========");MBProgressHUD*progressHUD=[[[MBPro......
    • [深入浅出Cocoa]iOS网络编程之Sock…
      一,iOS网络编程层次模型在前文《深入浅出Cocoa之Bonjour网络编程》中我介绍了如何在Mac系统下进行Bonjour编程,在那篇文章中也介绍过Cocoa中网络编程层次结构分为三层,虽然那篇演示的是Mac系统的例子,其实对iOS系统来说也是一样的。iOS网络编程层次结构也分为三层:Cocoa层:NSURL......
    • [iOS]GCD小结
      BriefIntroduction  GCD,全称GrandCentralDispath,是苹果开发的一种支持并行操作的机制。它的主要部件是一个FIFO队列和一个线程池,前者用来添加任务,后者用来执行任务。  GCD中的FIFO队列称为dispatchqueue,它可以保证先进来的任务先得到执行(但不保证一定先执行结束)。 ......
    • IOS实例变量和属性
      在IOS编程中,很多人没有理解实例变量与属性的区别,我根据自己的经验,这这里与大家分享下这里面的区别,下面我写一个简单的例子:.h@interfaceMyController:UIViewController{UILabel*_myLabel;//这里是实例变量声明}@property(nonatomic,retain)UILabel*myLabe......
    • iOS开发 UItableView中的单元…
      iOSiPhone开发UItableView中的单元格背景渐变渐变如果用背景图片,会让你的app臃肿。给APP瘦身,我们可以使用代码来解决渐变的问题。这篇文章是解决表格中的单元格的简便问题,同时解决单元格外边框问题。1:设置好开始颜色与结束颜色。推荐一个小工具,在chrome浏览器上安装一个扩展......