iOS跳转到AppStore常用方法

跳转到 AppStore 的常用方法,以下网址中将 id 后面的数字改为自己 App 的 id 即可。

1.通过Safari 输入网址跳转到 AppStore

  • http://itunes.apple.com/us/app/id1234567890

2.App 内部通过代码直接跳转到 AppStore

  • itms-apps://itunes.apple.com/cn/app/jie-zou-da-shi/id1234567890?mt=8

3.App 内部通过代码跳转到 AppStore 的评论区

  • itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=1234567890

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

/// appid替换成自己的appid
let appid : String = "1234567890"
/// URL替换成上面所提供的URL
let urlStirng = "itms-apps://itunes.apple.com/cn/app/jie-zou-da-shi/id\(appid)?mt=8"

if #available(iOS 10, *) {

if let url = URL(string: urlStirng) , UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
} else {

if let url = URL(string: urlStirng) , UIApplication.shared.canOpenURL(url) {
UIApplication.shared.openURL(url)
}
}
0%