iOS跳转App Store应用评论页
2016-04-26 15:32
627 查看
在这里把应用中用到的跳转App Store应用评论页的代码备份一下,之后应用不再支持iOS 7了,删掉之后担心再找不到。
首先iOS 7以下的版本、iOS 7和iOS 8+的跳转URL是不同的,所以必须区别处理,以下是代码逻辑:
这里先定义一个模板,根据不同的系统版本做处理,可以看到URL是不一样的
然后根据不同的系统版本做判断,将应用的appID替换模板中的APP_ID,最后调用系统接口打开URL就可以了
可以参看一下注释中提到的github上的项目代码。
首先iOS 7以下的版本、iOS 7和iOS 8+的跳转URL是不同的,所以必须区别处理,以下是代码逻辑:
这里先定义一个模板,根据不同的系统版本做处理,可以看到URL是不一样的
static NSString *templateReviewURL = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=APP_ID"; static NSString *templateReviewURLiOS7 = @"itms-apps://itunes.apple.com/app/idAPP_ID"; static NSString *templateReviewURLiOS8 = @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=APP_ID&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software";
然后根据不同的系统版本做判断,将应用的appID替换模板中的APP_ID,最后调用系统接口打开URL就可以了
NSString *reviewURL = [templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%@", appID]]; // iOS 7 needs a different templateReviewURL @see https://github.com/arashpayan/appirater/issues/131 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 7.1) { reviewURL = [templateReviewURLiOS7 stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%@", appID]]; } // iOS 8 needs a different templateReviewURL also @see https://github.com/arashpayan/appirater/issues/182 else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { reviewURL = [templateReviewURLiOS8 stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%@", appID]]; } if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:reviewURL]]) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:reviewURL]]; }
可以参看一下注释中提到的github上的项目代码。
相关文章推荐
- (4.4.14.1)Android_关于子控件和父控件的事件响应问题
- Android平台的跨进程通信——AIDL(上)
- iOS --延迟执行的几种方法
- Android View框架的draw机制
- Android自定义View
- Android中自定义View实现圆环等待及相关的音量调节效果
- Android 通过Stack管理Activity
- iOS 曲线/圆形/三角形/弧线等视图的实现
- Android View框架的layout机制
- (4.1.38)Android Loader 技术的简单实用
- Unity3D基于物理的物体拖拽
- android里shape与渐变色学习
- iOS图案锁,支持动画、图片、绘图
- JAVA_SE基础——60.初识Object
- Android源码学习笔记-同步机制
- Android 5.0 新增和改进的API
- 为什么明明安装了这个Android应用,却找不到
- html5 在Android 开发中的应用
- Android 通过xml 自定义图片
- Android开发6.0出现java.lang.UnsatisfiedLinkError...xxx.so has text relocations