Last active
December 28, 2025 17:45
-
-
Save AbodiDawoud/ec1b1b181406de077aaa981156d4a3ef to your computer and use it in GitHub Desktop.
YouTube url schemes for iOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| #Preview { | |
| Form { | |
| Section { | |
| Button("Search on YouTube") { | |
| UIApplication.shared.open(URL(string: "youtube://results?search_query=SwiftUI")!) | |
| } | |
| Button("Search on YouTube V2") { | |
| UIApplication.shared.open(URL(string: "youtube:///results?q=Apple Cupertino Park")!) | |
| } | |
| Button("Open YouTube") { | |
| UIApplication.shared.open(URL(string: "youtube://")!) | |
| } | |
| Button("Watch VideoID on YouTube") { | |
| UIApplication.shared.open(URL(string: "youtube://watch?v=mEKQvF4irBM")!) | |
| } | |
| Button("Open YouTube Channel") { | |
| UIApplication.shared.open(URL(string: "youtube://www.youtube.com/user/Expo")!) | |
| } | |
| Button("Open YouTube Subscriptions") { | |
| UIApplication.shared.open(URL(string: "youtube://www.youtube.com/feed/subscriptions")!) | |
| } | |
| Button("Open YouTube Watch Later") { | |
| UIApplication.shared.open(URL(string: "youtube://www.youtube.com/playlist?list=WL")!) | |
| } | |
| Button("Open YouTube History") { | |
| let url = URL(string: "youtube://www.youtube.com/history")! | |
| if UIApplication.shared.canOpenURL(url) { | |
| UIApplication.shared.open(url) | |
| } else { | |
| print("Can't open youtube history URL") | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment