0

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")!)
}
}
uz7
  • 159
  • 2
  • 15

1 Answers1

0

yes this is happening after iOS 9. you will find how to resolve this by following this answer

Hope this will help.

Community
  • 1
  • 1
KDeogharkar
  • 10,939
  • 7
  • 51
  • 95