Reputation: 145
I am working with Xcode 9 and Swift 4.0. I need to share a link to Facebook when clicking a button. I have integrated Facebook SDK.I have completed all the steps mentioned in Facebook documentation. But i can't share the link to facebook. My code is given below. It shows the error
-canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
if(FBSDKAccessToken.current() .hasGranted("publish_actions"))
{
self.postToFacebook()
}
else
{
let login: FBSDKLoginManager = FBSDKLoginManager()
login.logIn(withPublishPermissions: ["publish_actions"], from: self) { (result, error) in
if (error != nil) {
print("publish_actions: \(error!)")
} else if (result?.isCancelled)! {
print("publish_actions: Canceled")
} else if (result?.grantedPermissions.contains("publish_actions"))! {
print("publish_actions: permissions granted: \(String(describing: result?.token.tokenString))")
self.tokenString = "\(String(describing: result?.token.tokenString))"
self.postToFacebook()
//UserDefaults.standard.set(result?.token.tokenString, forKey: "facebook_token")
}
}
}
}`
func postToFacebook()
{
do{
var myContent = LinkShareContent(url: URL(string: "https://www.facebook.com/8MinuteWorkoutChallenge")!)
myContent.hashtag = Hashtag("#8MWC")
let shareDialog = ShareDialog(content: myContent)
shareDialog.mode = .native
shareDialog.failsOnInvalidData = true
shareDialog.completion = { result in
switch result {
case .success:
print("Share succeeded")
case .failed:
// self.shareButton.isHidden = true
print("failed")
case .cancelled:
print("Share cancelled")
}
}
try shareDialog.show()
}
catch {
print("Error: \(error)")
}
}
Upvotes: 0
Views: 211
Reputation: 13761
OSStatus error -10814
(aka kLSApplicationNotFoundErr
) occurs when an application cannot be found in the Launch Service's database. In other words, iOS cannot find an app with the scheme fbauth2
...It looks like you don't have Facebook installed on your test device :)
Ref: https://www.osstatus.com/search/results?platform=all&framework=all&search=10814
Upvotes: 1