iOS小技能:app信息查询(应用内调转到app store进行评论)
原创
©著作权归作者所有:来自51CTO博客作者#公众号:iOS逆向的原创作品,请联系作者获取转载授权,否则将追究法律责任
前言
应用内调转到app store进行评论:itms-apps://itunes.apple.com/app/idxxxxx?action=write-review
搜索接口:https://itunes.apple.com/search?term=xx&country=cn&limit=200&entity=software
APP 详细信息接口可用于检查版本: https://itunes.apple.com/cn/lookup?id=
APP 评论内容:https://itunes.apple.com/cn/rss/customerreviews/id=/sortBy=mostRecent/json
I app信息查询
1.1 应用分享
UIActivityViewController
NSURL *shareUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",@"itms-apps://itunes.apple.com/app/id",APPID]];
UIImage *shareImage = [UIImage imageNamed:@"green-unselected"];
NSString *shareText = NSLocalizedString(@"应用分享", nil);
NSArray *items = @[shareText,shareImage,shareUrl];
UIActivityViewController *activity = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
1.2 应用内调转到app store进行评论
showRateAlert
Rate it now
#define kAppStoreAddress @"itms-apps://itunes.apple.com/app/id162?action=write-review"
[[UIApplication sharedApplication] openURL:[NSURL
NSString *openAppStore = [NSString stringWithFormat: @"itms-apps://itunes.apple.com/app/id%@?action=write-review",APPID];//替换为对应的APPID
[[UIApplication sharedApplication] openURL:[NSURL
1.3 检查版本
- 按照位数进行依次比对,而不是去掉.分隔符再比较大小
- 去掉.分隔符比较大小【不推荐】
比如3.1.0 和3.0.16
如果是先去掉.分隔符再比较大小,这样会导致误判,因为3016 比3.1.0更大。
除非提前规定约定好,版本号至少固定4位,或者五位。
即 3.1.00 和3.0.16 . 但是这样容易因为人的疏忽而导致判断失误。
#pragma
- (void)checkTheVersionWithappid:(NSString*)appid{
[QCTNetworkHelper getWithUrl:[NSString stringWithFormat:@"http://itunes.apple.com/cn/lookup?id=%@",appid] params:nil successBlock:^(NSDictionary *result) {
if ([[result objectForKey:@"results"] isKindOfClass:[NSArray class]]) {
NSArray *tempArr = [result objectForKey:@"results"];
if (tempArr.count) {
NSString *versionStr =[[tempArr objectAtIndex:0] valueForKey:@"version"];
NSString *appStoreVersion = [versionStr stringByReplacingOccurrencesOfString:@"." withString:@""] ;
if (appStoreVersion.length==2) {
appStoreVersion = [appStoreVersion stringByAppendingString:@"0"];
}else if (appStoreVersion.length==1){
appStoreVersion = [appStoreVersion stringByAppendingString:@"00"];
}
NSDictionary *infoDic=[[NSBundle mainBundle] infoDictionary];
NSString* currentVersion = [[infoDic valueForKey:@"CFBundleShortVersionString"] stringByReplacingOccurrencesOfString:@"." withString:@""];
currentVersion = [currentVersion stringByReplacingOccurrencesOfString:@"." withString:@""];
if (currentVersion.length==2) {
currentVersion = [currentVersion stringByAppendingString:@"0"];
}else if (currentVersion.length==1){
currentVersion = [currentVersion stringByAppendingString:@"00"];
}
NSLog(@"currentVersion: %@",currentVersion);
if([appStoreVersion floatValue] > [currentVersion floatValue]){
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"发现新版本%@",versionStr] message:@"是否更新?" preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"稍后再说" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"取消更新");
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"立即去更新" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@",appid]];
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
}];
} else {
// Fallback on earlier vesions
[[UIApplication sharedApplication] openURL:url];
}
}]];
[[QCT_Common getCurrentVC] presentViewController:alertController animated:YES completion:nil];
}
}
}
} failureBlock:^(NSError *error) {
NSLog(@"检查版本错误: %@",error);
}];
}
see also
iOS小技能:拨号、发邮件、短信、应用间跳转