Skip to content

Instantly share code, notes, and snippets.

@susieyy
Created January 14, 2017 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save susieyy/3a3f1a06923994c1e32845a5e87e8a44 to your computer and use it in GitHub Desktop.
Save susieyy/3a3f1a06923994c1e32845a5e87e8a44 to your computer and use it in GitHub Desktop.
#swtws
protocol FBAppPresentable {}
extension FBAppPresentable where Self: UIViewController {
func openFacebookUrl(url: NSURL) {
guard let userId = url.lastPathComponent where Global.fbInstalled else {
presentWebViewController(of: url); return
}
guard let encodedUrl = NSURL.encoded(of: "fb://profile/\(userId)") else {
presentWebViewController(of: url); return
}
UIApplication.sharedApplication().openURL(encodedUrl)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment