I have added "instagram" to my LSApplicationQueriesSchemes in the Info.plist file but it still doesn't open up neither safari nor instagram when the following function is called:
func openinstagram () {
let instaurl = URL(fileURLWithPath: "https://www.instagram.com/(myusername)/?hl=de")
if UIApplication.shared.canOpenURL(instaurl) {
UIApplication.shared.open(instaurl, options: [:] ) { (sucess) in
print("url opened")
}
}
}
It doesn't tell me anything but "url opened" in the Log
What is the solution to this? Thank you in advance
You can try out this.
URL(fileURLWithPath:)
use to get file starting with /
URL(string:)
is create web url
func openinstagram () {
if let instaurl = URL(string: "https://www.instagram.com/(myusername)/?hl=de"),
UIApplication.shared.canOpenURL(instaurl) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(instaurl)
} else {
UIApplication.shared.openURL(instaurl)
}
}
}