func click(){
// let url = URL.init(string: "tel:15088132368") // 打电话
// let url = URL.init(string: "sms:15088132368") // 发短信
// let url = URL.init(string: "mailto:15088132368@163.com") // 发邮件
// let url = URL.init(string: "https://www.baidu.com") // 跳转链接
// let url = URL.init(string: "https://itunes.apple.com/us/app/kuai- quan-cai-gou/id1134898622?l=zh&ls=1&mt=8") // 跳转到appstore
/*
1、别人app的info->URL Types ->URL Schemes 设置的 kuaiQuan(像微信提供的weixin://)
2、在info.plist里面设置白名单,添加字段:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>kuaiQuan</string>
</array>
3、在safair浏览器也可以打开:kuaiQuan://
4、两个APP间参数传递,在后面添加参数,在另一个APP里面调用func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool 方法可以获取到参数
*/
// let url = URL.init(string: "kuaiQuan://") // 不带参数
let url = URL.init(string: "kuaiQuan://www.yujinhai.com/index?title=hello&detail=world") // 带参数
if UIApplication.shared.canOpenURL(url!) {
let options = [UIApplicationOpenURLOptionUniversalLinksOnly : false]
UIApplication.shared.open(url!, options: options) { (isOpen) in
print(isOpen)
}
} else {
// 弹出提示(不然会被苹果拒绝的)
}
}
网友评论