Skip to content

Instantly share code, notes, and snippets.

@susieyy susieyy/FBAppPresentable.swift Secret
Created Jan 14, 2017

Embed
What would you like to do?
#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
You can’t perform that action at this time.