美文网首页
App检测版本更新

App检测版本更新

作者: Isspace | 来源:发表于2017-01-13 16:56 被阅读199次

参考文章:http://blog.csdn.net/xiaoxuan415315/article/details/9383453

http://www.cnblogs.com/weilaikeji/p/3331772.html


自己封装检测方法

+ (void)checkAppVersionWithCompleteBlock:(void(^)(BOOLisTheNewest))completeBlock {

//请求链接

   NSString*requestUrl =@"https://itunes.apple.com/lookup?id=1141783035";

//请求

   AFHTTPSessionManager*httpManager = [AFHTTPSessionManagermanager];

   httpManager.requestSerializer.timeoutInterval=15.f;

   httpManager.responseSerializer= [AFJSONResponseSerializerserializer];

   //@"text/plain", @"application/json",@"text/json",@"text/javascript",@"text/html"

   httpManager.responseSerializer.acceptableContentTypes= [NSSetsetWithObjects:

                 @"text/plain",

                 @"application/json",

                 @"text/json",

                 @"text/javascript",

                 @"text/html",nil];

  [httpManagerPOST:requestUrlparameters:nilprogress:nilsuccess:^(NSURLSessionDataTask*_Nonnulltask,id_NullableresponseObject) {

  NSLog(@"------response = %@",responseObject);

  //trackViewUrl releaseNotes

//获取当前版本号

  NSString* currentVersion = [[NSBundlemainBundle]objectForInfoDictionaryKey:@"CFBundleShortVersionString"];

  NSArray*curVersion = [currentVersioncomponentsSeparatedByString:@"."];

  NSString* curV = [curVersioncomponentsJoinedByString:@""];

  NSIntegercurrentVersionNum = [curVintegerValue];

  NSLog(@"current = %ld",currentVersionNum);

  NSArray*results = responseObject[@"results"];

  NSDictionary*appInfo = results[0];

//获取App Store上的最新版本号

  NSString*latestVersion = appInfo[@"version"];

  NSArray*laVersion = [latestVersioncomponentsSeparatedByString:@"."];

  NSString* laV = [laVersioncomponentsJoinedByString:@""];

  NSIntegerlatestVersionNum = [laVintegerValue];

  NSLog(@"latest = %ld",latestVersionNum);

//判断版本号

  if(currentVersionNum >= latestVersionNum) {

  completeBlock(YES,nil);

  }else{

  completeBlock(NO, appInfo);

}

  NSString*trackViewUrl = appInfo[@"trackViewUrl"]; //跳转到App Store的url

  NSString*releaseNotes = appInfo[@"releaseNotes"]; //线上新版本的信息

  }failure:^(NSURLSessionDataTask*_Nullabletask,NSError*_Nonnullerror) {

  }];

}

//在你想要检测的地方使用

[CheckAppVersioncheckAppVersionWithCompleteBlock:^(BOOLisTheNewest,NSDictionary* appInfo) {

  if(!isTheNewest) {

  NSString*trackViewUrl = appInfo[@"trackViewUrl"];

  NSString*releaseNotes = appInfo[@"releaseNotes"];

  [weakSelfshowAlertViewWithTitle:@"发现最新版本!"message:releaseNotescancelButton:@"下次再 说"confirmButton:@"去更新"cancelAction:^{

  }confirmAction:^{

  [[UIApplicationsharedApplication]openURL:[NSURLURLWithString:trackViewUrl]];

}];

}

}];

请求获得结果信息:

response:

resultCount = 1;

results =     (

{

advisories =             (

);

appletvScreenshotUrls =             (

);

artistId = 1141783034;

artistName = "Shanghai Minai Finance Co., Ltd.";

artistViewUrl = "https://itunes.apple.com/us/developer/shanghai-minai-finance-co./id1141783034?uo=4";

artworkUrl100 = "http://is2.mzstatic.com/image/thumb/Purple111/v4/5b/d9/a6/5bd9a646-2e0e-9750-54a2-d419160f37c7/source/100x100bb.jpg";

artworkUrl512 = "http://is2.mzstatic.com/image/thumb/Purple111/v4/5b/d9/a6/5bd9a646-2e0e-9750-54a2-d419160f37c7/source/512x512bb.jpg";

artworkUrl60 = "http://is2.mzstatic.com/image/thumb/Purple111/v4/5b/d9/a6/5bd9a646-2e0e-9750-54a2-d419160f37c7/source/60x60bb.jpg";

bundleId = "com.minai.MinaiDai";

contentAdvisoryRating = "4+";

currency = USD;

currentVersionReleaseDate = "2017-01-05T22:27:46Z";

description = "\U4e0a\U6d77\U6c11\U7231\U4e92\U8054\U7f51\U91d1\U878d\U4fe1\U606f\U670d\U52a1\U6709\U9650\U516c\U53f8\U662f\U4e00\U5bb6\U4e92\U8054\U7f51\U91d1\U878d\U670d\U52a1\U5e73\U53f0\Uff0c\U65e8\U5728\U4e3a\U6709\U878d\U8d44\U9700\U6c42\U7684\U5c0f\U5fae\U4f01\U4e1a\U548c\U4e2a\U4eba\U5efa\U7acb\U9ad8\U6548\U3001\U900f\U660e\U3001\U5b89\U5168\U3001\U4fbf\U6377\U7684\U4e92\U8054\U7f51\U91d1\U878d\U670d\U52a1\U3002\n\U65b0\U624b\U6ce8\U518c\U7acb\U5373\U9001\U4f53\U9a8c\U91d1\Uff0c \U6295\U8d44\U4f53\U9a8c\U6807\U518d\U9001888\U5143\U7ea2\U5305\Uff0c\U65b0\U624b\U5b9d\U5e74\U5316\U7387\U9ad8\U8fbe18%\Uff0c\U5230\U671f\U518d\U8fd420\U5143\U73b0\U91d1.\n\U6c11\U7231\U8d37\U5e73\U53f0\U2014\U201c\U4f18\U8d8a\U8d44\U4ea7\Uff0c\U8d85\U9ad8\U6536\U76ca\Uff0c\U5b89\U5168\U4fdd\U969c\U3002\U201d\U4e00\U4e2a\U627f\U8bfa\U201c\U672c\U606f\U4fdd\U969c\U201d\U7684\U9760\U8c31\U4e92\U8054\U7f51\U91d1\U878d\U5e73\U53f0\U3002\n\n\U529f\U80fd\U4eae\U70b9\Uff1a\n1. \U64cd\U4f5c\U7b80\U5355\Uff1a\U7ebf\U4e0a\U64cd\U4f5c\U6ce8\U518c\U3001\U5145\U503c\U3001\U6295\U8d44\U4e00\U952e\U641e\U5b9a\n2. \U4ea7\U54c1\U7cbe\U9009\Uff1a\U4ea7\U54c1\U8be6\U60c5\U4e00\U76ee\U4e86\U7136\Uff0c\U6295\U8d44\U5168\U65b9\U4f4d\U4e86\U89e3\n3. \U52a8\U6001\U66f4\U65b0\Uff1a\U62a2\U6807\U3001\U6295\U8d44\Uff0c\U5148\U4eba\U4e00\U6b65\n4. \U4f1a\U5458\U5347\U7ea7\Uff1a\U5b8c\U6210\U65b0\U624b\U4efb\U52a1\Uff0c\U8f7b\U677e\U53d8\U8eab\U9752\U94dc\U4f1a\U5458\n5. \U8d44\U91d1\U660e\U7ec6\Uff1a\U6295\U8d44\U3001\U5956\U52b1\Uff0c\U8d44\U91d1\U660e\U7ec6\U5168\U7eaa\U5f55\Uff0c\U79d2\U53d8\U653e\U5fc3\U6295\U8d44\U4eba\n\n\U3010\U6ce8\U518c\U4e13\U4eab\U3011\n1\Uff0e\U6d3b\U52a8\U671f\U95f4\U5728\U6c11\U7231\U8d37\U6ce8\U518c\U7acb\U5373\U90011888\U5143\U4f53\U9a8c\U91d1\Uff0c\U6295\U8d44\U4f53\U9a8c\U6807\U518d\U9001888\U5143\U7ea2\U5305\Uff1b\n2\Uff0e\U65b0\U624b\U5b9d\U5e74\U5316\U7387\U9ad8\U8fbe18%\Uff0c\U6295\U8d44\U66f4\U90011.0%\U52a0\U606f\U52b5\Uff0c\U5230\U671f\U900120\U5143\U73b0\U91d1\Uff1b\n3\Uff0e\U6d3b\U52a8\U671f\U95f4\Uff0c\U65b0\U624b\U6ce8\U518c\U591a\U79cd\U798f\U5229\U7b49\U4f60\U6765\U62ff\Uff1b\n\U3010\U5b89\U5168\U4fdd\U969c\U3011\n1.\U8fc4\U4eca\U6240\U6709\U672c\U606f\U5230\U671f\U56de\U6b3e\Uff0c\U96f6\U574f\U8d26\U7387\n2.\U4e0e\U4e0a\U6d77\U5bcc\U53cb\U91d1\U878d\U670d\U52a1\U96c6\U56e2\U5408\U4f5c\Uff0c\U652f\U4ed8\U5b89\U5168\U4fdd\U969c\n3.\U6743\U5a01\U91d1\U878d\U6295\U8d44\U884c\U4e1a\U4ece\U4e1a\U4eba\U5458\Uff0c\U4e30\U5bcc\U7684\U91d1\U878d\U501f\U8d37\U9879\U76ee\U7ecf\U9a8c\n\U3010\U8d44\U8d28\U8363\U8a89\U3011\n1. \U300a\U4e0a\U6d77\U4fe1\U606f\U5316\U300b\U7406\U4e8b\U4f1a\U526f\U7406\U4e8b\U957f\U5355\U4f4d\n2.  \U4e0a\U6d77\U91d1\U878d\U4fe1\U606f\U884c\U4e1a\U534f\U4f1a\U4f1a\U5458\n\U3010\U5ba2\U670d\U70ed\U7ebf\U3011\n 400-821-2165    021-60484514";

features =             (

);

fileSizeBytes = 53271552;

formattedPrice = Free;

genreIds =             (

6002,

6015

);

genres =             (

Utilities,

Finance

);

ipadScreenshotUrls =             (

);

isGameCenterEnabled = 0;

isVppDeviceBasedLicensingEnabled = 1;

kind = software;

languageCodesISO2A =             (

EN,

ZH

);

minimumOsVersion = "8.0";

price = 0;

primaryGenreId = 6002;

primaryGenreName = Utilities;

releaseDate = "2016-09-18T08:42:11Z";

releaseNotes = "1.\U4fee\U590d\U7f51\U9875\U7f51\U5740\U53d8\U6210https\U52a0\U8f7d\U5931\U8d25\U7684\U95ee\U9898\Uff1b\n2.\U6295\U8d44\U5217\U8868\U65b0\U589e\U4f01\U4e1a\U8d37\U3001\U8f66\U8d37\Uff0c\U4ea7\U54c1\U8fdb\U884c\U6574\U5408\Uff1b\n3.\U6295\U8d44\U8be6\U60c5\U9875\U4fe1\U606f\U5c55\U793a\U6539\U7248\Uff0c\U66f4\U52a0\U6761\U7406\U6e05\U6670\Uff1b\n4.\U9996\U9875\U754c\U9762\U8fdb\U884c\U4f18\U5316\U3002";

screenshotUrls =             (

"http://a5.mzstatic.com/us/r30/Purple122/v4/e1/a5/a0/e1a5a0e2-04e5-b1b0-9649-1d87878d53a4/screen696x696.jpeg",

"http://a5.mzstatic.com/us/r30/Purple111/v4/73/07/79/730779b2-324d-f6d9-7c09-c5069964228a/screen696x696.jpeg",

"http://a3.mzstatic.com/us/r30/Purple122/v4/85/1e/77/851e773a-7fe7-0941-69fd-de69cef9a465/screen696x696.jpeg",

"http://a3.mzstatic.com/us/r30/Purple111/v4/71/58/1b/71581bcb-2ffb-d990-ed1b-d3e6b42da293/screen696x696.jpeg",

"http://a1.mzstatic.com/us/r30/Purple111/v4/1f/58/91/1f589151-67cf-81cd-691a-e00b83c8a4f6/screen696x696.jpeg"

);

sellerName = "Shanghai Minai Finance Co., Ltd.";

supportedDevices =             (

iPad2Wifi,

iPad23G,

iPhone4S,

iPadThirdGen,

iPadThirdGen4G,

iPhone5,

iPodTouchFifthGen,

iPadFourthGen,

iPadFourthGen4G,

iPadMini,

iPadMini4G,

iPhone5c,

iPhone5s,

iPhone6,

iPhone6Plus,

iPodTouchSixthGen

);

trackCensoredName = "\U6c11\U7231\U8d37";

trackContentRating = "4+";

trackId = 1141783035;

trackName = "\U6c11\U7231\U8d37";

trackViewUrl = "https://itunes.apple.com/us/app/min-ai-dai/id1141783035?mt=8&uo=4";

version = "2.0.0";

wrapperType = software;

}

);

相关文章

网友评论

      本文标题:App检测版本更新

      本文链接:https://www.haomeiwen.com/subject/lpysbttx.html