I have a Facebook button in my app which is linked to my Facebook page however it open up in safari rather than the Facebook app. I have also linked twitter that opens up in the app first and not safari which is how i want it. My code for both buttons is the same so i don't understand why it is behaving this way?
@IBAction func openFB(sender: AnyObject) {
if UIApplication.sharedApplication().canOpenURL(NSURL(string: "fb://profile/XXXXXXXXX")!) {
UIApplication.sharedApplication().openURL(NSURL(string: "fb://profile/XXXXXXXXX")!)
} else {
UIApplication.sharedApplication().openURL(NSURL(string: "https://facebook.com/XXXXXXXX")!)
}
}
@IBAction func openTW(sender: AnyObject) {
if UIApplication.sharedApplication().canOpenURL(NSURL(string: "tw://profile/XXXXXXX")!) {
UIApplication.sharedApplication().openURL(NSURL(string: "fb://profile/XXXXXXXX")!)
} else {
UIApplication.sharedApplication().openURL(NSURL(string: "https://twitter.com/XXXXXXXXXX")!)
}
}