swift5 應(yīng)用內(nèi)打開瀏覽器和應(yīng)用商店
相關(guān)代碼如下:
/// 打開瀏覽器
func openSafari() {
if #available(iOS 11.0, *) {
let safariVC = SFSafariViewController(url: URL(string: "https://www.baidu.com")!)
present(safariVC, animated: true)
}
}
/// 打開應(yīng)用商店
func openAppStore() {
let storeVC = SKStoreProductViewController()
if #available(iOS 11.0, *) {
let param = [SKStoreProductParameterITunesItemIdentifier:"836500024"]
storeVC.loadProduct(withParameters: param) { isSuccess, error in
print("aaaaaaaaaaaaaaaaaaaaaaa\(isSuccess)")
}
present(storeVC, animated: true)
} else {
}
}