How can I open a link in chrome from my iOS app? (Swift)

时间:2019-04-16 22:40:32

标签: swift google-chrome

I know I can open a url in safari with:

let myUrl = URL(string: "http://website.com")!
UIApplication.shared.open(myUrl, options: [:], completionHandler: nil)

Is there any way to open it in the google chrome app?

1 个答案:

答案 0 :(得分:0)

To open a url in chrome, you need to:

  1. Add googlechrome to your app's Info.plist file (and googlechromes for https)

enter image description here

  1. Change your url to use googlechrome:// instead of http://
let myChromeUrl = URL(string: "googlechrome://website.com")!
UIApplication.shared.open(myChromeUrl, options: [:], completionHandler: nil)