更新

2016-12-13  本文已影响12人  小龙是只猫

好吧,对于苹果审核来说蛋疼的一逼,上传了三次,每次的审核都因为各种原因给打回来,最后一次是因为支付虚拟服务需要通过虚拟货币购买,可是收30%的提成,导致了公司不同意这种方法,于是就各种问小伙伴规避方法,下面的是更新:


NSString*appleID =@"your app appleID";

NSMutableURLRequest*request = [[NSMutableURLRequestalloc] init];

[request setURL:[NSURLURLWithString:[NSStringstringWithFormat:@"http://itunes.apple.com/lookup?id=%@",appleID]]];

[request setHTTPMethod:@"GET"];

NSData*returnData = [NSURLConnectionsendSynchronousRequest:request returningResponse:nil error:nil];

NSMutableDictionary*jsondata = [NSJSONSerializationJSONObjectWithData:returnData options:NSJSONReadingMutableLeaveserror:nil];

NSLog(@"jsondata===%@",jsondata);

NSMutableArray*resultsArr = [jsondata objectForKey:@"results"];

NSMutableDictionary*infodic = [resultsArr objectAtIndex:0];

NSString*latestVersion = [infodic objectForKey:@"version"];

NSString*trackViewUrl = [infodic objectForKey:@"trackViewUrl"];

NSLog(@"%@",trackViewUrl);

NSLog(@"latestVersion=%@",latestVersion);

[[NSUserDefaultsstandardUserDefaults]setObject:trackViewUrl forKey:@"trackViewUrl"];

NSLog(@"uurrll=%@",trackViewUrl);

NSDictionary*infoDict = [[NSBundlemainBundle] infoDictionary];

NSString*currentVersion = [infoDict objectForKey:@"CFBundleShortVersionString"];

NSLog(@"当前版本号是%@",currentVersion);

NSLog(@"doublecurrent=%@",currentVersion);

if([currentVersion isEqualToString:latestVersion]) {

NSLog(@"版本相同 不用更新");

[[NSUserDefaultsstandardUserDefaults] removeObjectForKey:@"updateVersion"];

[[NSUserDefaultsstandardUserDefaults] setObject:@"no"forKey:@"updateVersion"];

}else

{NSArray* newVerAry = [latestVersion componentsSeparatedByString:@"."];

NSArray* curVerAry = [currentVersion componentsSeparatedByString:@"."];

for(inti =0; i < [newVerAry count] || i < [curVerAry count]; i++)

{

intnewSubVer, curSubVer;

// 如果子版本号数不足,作为0处理

if(i >= [newVerAry count])

{

newSubVer =0;

}

else

{

newSubVer = [[newVerAry objectAtIndex:i] intValue];

}

if( i >= [curVerAry count])

{

curSubVer =0;

}

else

{

curSubVer = [[curVerAry objectAtIndex:i] intValue];

}

if( newSubVer > curSubVer)

{

NSLog(@"当前版本低 ,需要更新");

[[NSUserDefaultsstandardUserDefaults] removeObjectForKey:@"updateVersion"];

[[NSUserDefaultsstandardUserDefaults] setObject:@"yes"forKey:@"updateVersion"];

NSLog(@"version == yes");

return;

}

elseif( newSubVer < curSubVer)

{

NSLog(@"当前版本高 不需要更新");

[[NSUserDefaultsstandardUserDefaults] removeObjectForKey:@"updateVersion"];

[[NSUserDefaultsstandardUserDefaults] setObject:@"no"forKey:@"updateVersion"];

return;

}

}

}

有意见小伙伴多多指导,反正我是只只吃菜的鸟

上一篇下一篇

猜你喜欢

热点阅读