Skip to content

Latest commit

 

History

History
23 lines (17 loc) · 448 Bytes

open-a-browser-url.md

File metadata and controls

23 lines (17 loc) · 448 Bytes

Open A Browser URL

Category: Swift

You can open the default system browser for a given URL using Swift.

To open on iOS:

if let url = URL(string: "https://www.soundbytes.dev"), UIApplication.shared.open(url) {
    // On success
    print("Browser opened")
}

To open on macOS:

if let url = URL(string: "https://www.soundbytes.dev"), NSWorkspace.shared.open(url) {
    // On success
    print("Browser opened")
}