Open AppStore through button

前端 未结 15 813
逝去的感伤
逝去的感伤 2020-12-12 22:18

Could you guys help me to translate the following code into Swift?

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@\"itms://itunes.apple.com         


        
15条回答
  •  醉酒成梦
    2020-12-12 22:45

    Swift 5

    let url = "your app url"
    if #available(iOS 10.0, *) {
        UIApplication.shared.open(url, options: [:], completionHandler: nil)
     } 
    else {
        // Earlier versions 
        if UIApplication.shared.canOpenURL(url as URL) {
            UIApplication.shared.openURL(url as URL)
        }
    }
    

提交回复
热议问题