How can I open Facebook and Instagram app by tapping on a button in swift
? Some apps redirect to the Facebook app and open a specific page. How can I do the sam
Based on accepted answer here is the way to do this more elegantly with Swift 4
UIApplication.tryURL([
"instagram://user?username=johndoe", // App
"https://www.instagram.com/johndoe/" // Website if app fails
])
And truly remember to add the scheme to allow the app to open. However even if you forget that instagram will open in Safari.
The tryUrl is an extension similar to presented here: https://stackoverflow.com/a/29376811/704803