iOS常用系统功能相关DevSupport当仓央嘉措遇上纳兰性德

iOS 跳转到App Store下载APP和评分功能实现

2017-08-03  本文已影响537人  绚雨蓝了个枫

在创建并存储 App 的 iTunes Connect 中可以查看到App对应的Apple ID

#define APPID @"Apple ID"
A. 跳转到应用详情页
 //1.cn代表中国。在Safari浏览器打开链接是中文介绍
 NSString *urlStr = [NSString stringWithFormat:@"https://itunes.apple.com/cn/app/id%@", APPID];
        
 //2.us代表美国。在Safari浏览器打开链接是英文介绍
 NSString *urlStr = [NSString stringWithFormat:@"https://itunes.apple.com/us/app/id%@", APPID];
        
 //3.和1跳转相同
 NSString *urlStr = [NSString stringWithFormat:@"https://itunes.apple.com/cn/app/apple-store/id%@", APPID];
        
 //4.和2跳转相同
 NSString *urlStr = [NSString stringWithFormat:@"https://itunes.apple.com/app/id%@", APPID];
        
 //5.以 itms-apps:// 或 https:// 开头的应用详情页链接,跳转到AppStore
 NSString *urlStr = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=%@", APPID];
        
 //6.以 itms:// 开头的应用详情页连接,会跳转到 iTunes Store,打开的仍然是应用的下载页
 NSString *urlStr = [NSString stringWithFormat:@"itms://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=%@", APPID];

 //打开链接地址
 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];

结论:

跳转到应用详情页
以 itms-apps:// 或 https:// 开头的应用详情页链接,跳转到AppStore。
以 itms:// 开头的应用详情页连接,会跳转到 iTunes Store,打开的仍然是应用的下载页。

推荐:

方法1、3、5。

B. 跳转到应用评分页
 //1.itms-apps:// 开头
 NSString *urlStr = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@",APPID];
       
 //2.itms:// 开头
 NSString *urlStr = [NSString stringWithFormat:@"itms://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@",APPID];
        
 //3.itms-apps:// 开头
 NSString *urlStr = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@&pageNumber=0&sortOrdering=2&mt=8", APPID];
        
 //4.https:// 开头 此时的链接不可以,打开之后就跳转到iPhone自带的【音乐】APP里面了。
 NSString *urlStr = [NSString stringWithFormat:@"https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&id=%@",APPID];

 //打开链接地址
 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];
结论:

跳转到应用评分页
以 itms-apps://和itms://开头的链接都可以跳转到AppStore。但是以https:// 开头的链接不可以。

推荐:

方法1、2、3。

C. 总结

其中参数mt:8的含义为:

mt 代表 meta-type,有效值如下:
1 Music
2 Podcasts
3 Audiobooks
4 TV Shows
5 Music Videos
6 Movies
7 iPod Games
8 Mobile Software Applications
9 Ringtones
10 iTunes U
11 E-Books
12 Desktop Apps

https:// 相比较于 itms:// 或者 itms-apps:// 的区别在哪里呢?

itms-apps请求:
iOS系统中可以从应用内或通过Safari跳转App商店;
OS X系统中无法通过浏览器跳转;

https请求:
iOS系统中可以通过大部分浏览器跳转App商店;
OS X系统中可以通过浏览器跳转iTunes商店;

以上示例皆是在真机上面测试得到的结果。

参考:

iOS跳转AppStore相关

上一篇下一篇

猜你喜欢

热点阅读