检查应用
- (void)___checkVersion {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *string = [NSString stringWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/lookup?id=%@",k_app_store_app_id]] encoding:NSUTF8StringEncoding error:nil];
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
if(![dataisKindOfClass:[NSDataclass]] || !data) {
return;
}
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
/*
"resultCount":0,
"results": []
*/
//获得上线版本号
NSString *newVersion = [[[dic objectForKey:@"results"] firstObject] objectForKey:@"version"];
NSString *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
if(![newVersionisEqualToString:currentVersion]) {
[self ___showTipForVersion];
}
});
[self ___jumpToAppStore];
}
- (void)___showTipForVersion {
}
- (void)___jumpToAppStore {
NSString *urlStr = [[NSString alloc] initWithFormat:@"https://itunes.apple.com/lookup?id=%@",k_app_store_app_id];
NSURL* url = [NSURLURLWithString:urlStr];
[[UIApplication sharedApplication] openURL:url];
}
网友评论