How do I get a button to link to a facebook account using the facebook application and if it isn't installed then use Safari? I have used the code in the following and I believe it should work but it only uses Safari.
@IBAction func btnFacebook(_ sender: UIButton) {
let facebook_URL_ID: NSURL? = NSURL(string: "fb://profile/##########")
let facebook_URL_Web: NSURL? = NSURL(string: "https://www.facebook.com/##########")
if UIApplication.shared.canOpenURL(facebook_URL_ID! as URL) {
UIApplication.shared.open(facebook_URL_ID! as URL, completionHandler: nil)
}
else {
UIApplication.shared.open(facebook_URL_Web! as URL)
}
}