Skip to content
This repository has been archived by the owner on Nov 2, 2019. It is now read-only.

Facebook Share SDK (swift) always return 'success' if user cancel the share dailog. Also if user successfully share the 'LInkShareContent' it return empty dictionary. #171

Closed
smahajan28 opened this issue Aug 18, 2017 · 29 comments
Labels
bug Something is broken or being fixed objc sdk This issue is associate with underlying Objective-C SDK

Comments

@smahajan28
Copy link

smahajan28 commented Aug 18, 2017

We are using Facebook Share SDK for swift ver 0.2. Whenever we try to share the Link content, we are always getting success in return even if user cancel the operation. Since there are 3 cases: success, cancelled, failed but we are always getting success in this case.
Also if user successfully post the link on his/her wall then we were expecting the post id in the response but again the response is success burt with empty dictionary. We are unable to calculate the number of share user is performing because of the same issue.

API we are using is listed below:

let shareContent = LinkShareContent(url: <URL TO SHARE>, title: <TEXT TO SHARE>, description: "", quote: "", imageURL: <IMAGE URL> ?? .none)
do {
  try ShareDialog.show(from: self, content: shareContent, completion: { (result) in
    switch result {
    case .success(let _): // Always getting success with empty dictionary
        completion(true)
    case .cancelled, .failed(_):
        completion(false)
    }
  })
}
catch {
    print("error")
    completion(false)
}

We are using iOS version 10.3.2

Facebook SDK version:
0.2

@f2rozen541
Copy link

I just meet the same issue in Android sdk, can Facebook developers solve the problem?

@DisappearPing
Copy link

DisappearPing commented Sep 28, 2017

ios 11 share always return "cancelled"

@royherma
Copy link

royherma commented Oct 9, 2017

@DisappearPing
Try adding this in AppDelegate

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
    SDKApplicationDelegate.shared.application(app, open: url, options: options)
}

@codytwinton
Copy link
Contributor

@smahajan28 - I'm in process of closing old issues to help us focus on improving this SDK. If you're still running into this issue, please feel free to reopen this issue.

@royherma
Copy link

@codytwinton I'm unable to open the issue, but I can attest that there are still issues with this flow.

Specifically, opening the FB share dialog and sharing a post correctly calls the success statement on the completion callback, however the "postId" is always nil.

Furthermore, even if the user doesn't submit the post, success is still returned, making it impossible to validate if a user successfully shared a post.

@royherma
Copy link

@smahajan28 were you able to solve this?

@codytwinton
Copy link
Contributor

@smahajan28 @royherma - good to know. I’ll reopen the issue and use it to track progress.

In the mean time, if anyone finds a solution, feel free to submit a pull request!

@codytwinton codytwinton reopened this Jul 25, 2018
@codytwinton codytwinton added the bug Something is broken or being fixed label Jul 25, 2018
@royherma
Copy link

@codytwinton Do you know if this works for anyone at all on iOS w/ Swift?

@royherma
Copy link

Also, I am using Firebase for my project - perhaps this could be causing issues?

@codytwinton
Copy link
Contributor

@royherma - We're in process of resolving the best way to improve this SDK, but I don't believe that Firebase would be conflicting with this SDK. Stay tuned for updates.

In the meantime, if anyone finds a solution, feel free to submit a pull request!

@royherma
Copy link

royherma commented Jul 26, 2018

Got it - also, here is my code for reference:

let myContent = LinkShareContent(url: kFacebookAppShareURL, title: "Cryptonomy", description: nil, quote: "Cryptonomy is an exclusive social network for crypto-enthusiasts where you can track and discuss everything crypto. It's where crypto happens! \n\nI highly recommend it \(kShareHashTag)", imageURL: nil)
let shareDialog = ShareDialog(content: myContent)
shareDialog.mode = .automatic
shareDialog.failsOnInvalidData = true
shareDialog.completion = { result in
    // Handle share results
    switch result {
    case .success(let response):
        if let postId = response.postId {
            osPrint("Share succeeded")
            logEvent(eventName: "User conversion alert action", attributes: ["action": "Succesfully shared to Facebook", "postId": postId])
            self.giveUserReward()
        }
        break
    case .failed(let error):
        logEvent(eventName: "User conversion alert action", attributes: ["action": "Failed sharing to Facebook", "error": error.localizedDescription])
        self.showErrorAlert(message: error.localizedDescription)
        break
    case .cancelled:
        logEvent(eventName: "User conversion alert action", attributes: ["action": "Cancelled sharing to Facebook"])
        break
    }
}

do {
    try shareDialog.show()
} catch {
    //error displaying facebook dialog
}

@royherma
Copy link

royherma commented Aug 8, 2018

@codytwinton any update on this? I haven't been able to get any confirmation that this works for anyone, or that your team reproduced the issue. I have a feature in my app that relies on this flow working correctly (as I imagine many others do), but have yet to get any updates from your team. I wouldn't expect too much but I have always held Facebook to a higher standard!

Also, let me know if I can help in any way.

Thanks

@codytwinton
Copy link
Contributor

@royherma - I apologize for the delay. We'll do our best to get this resolved in the near future.

@AndrewSB
Copy link
Contributor

AndrewSB commented Aug 8, 2018

@royherma for now, as a workaround, you could use the Objective-C sharing API instead of the swift one.

@royherma
Copy link

royherma commented Aug 9, 2018

@AndrewSB Just tried, same issue - submitting a post returns any empty results dictionary. Tapping on "Done" without posting (and once logged in with a user) returns the same thing.

Using FBSDKShareKit (4.21.0).

Here is my logic (quite simple):

let content = FBSDKShareLinkContent()
content.contentTitle = "This is a test url"
content.contentURL = URL(string:"http://google.com")
FBSDKShareDialog.show(from: self, with: content, delegate: self)

Are you able to get different results?

@royherma
Copy link

royherma commented Aug 9, 2018

This leads me to suspect that something in the url callback / app delegate is incorrect or has been changed, resulting in wrong result values (just a hunch)

@codytwinton
Copy link
Contributor

@royherma - Thanks for reproducing this with the Objective-C SDK. Since this issue affects that SDK, can you head over here and file a bug? https://developers.facebook.com/support/bugs/

Doing this will ensure that this issue gets resolved in a timely fashion!

@codytwinton codytwinton added the objc sdk This issue is associate with underlying Objective-C SDK label Aug 9, 2018
@royherma
Copy link

royherma commented Aug 9, 2018

@codytwinton Done - Hoping for a swift solution 🙏

Thanks for staying in the loop.

@codytwinton
Copy link
Contributor

@royherma - Ha!

Image

@Jignesh1805
Copy link

#171 (comment)

Always return cancelled result can you help me ?

@royherma
Copy link

The objective-c library actually didn't solve my issue, however after filing a bug on facebook and hearing back, I think the solution is related to making sure the app is question has user_posts permission enabled (must go through FB auth review...arghhh) @Jignesh1805 @codytwinton

@Jignesh1805
Copy link

Ok i will try to user_posts permission enabled.
thank you @royherma

@Jignesh1805
Copy link

#171 (comment) using this code and return postid nil how to solve this ?
please help me

@codytwinton
Copy link
Contributor

@Jignesh1805 - Thanks for adding this in. I'm going to reopen this issue. I'm actively working on some internal improvements to the underlying iOS SDK, which should offer greater stability for this SDK.

In the meantime, if anyone finds the the solution to this issue, feel free to submit a pull request.

@codytwinton codytwinton reopened this Aug 30, 2018
@Manpreetkaurrao
Copy link

getting this issue....... as user just clicks done , without sharing the post it gives a callBack to success and in result field, its not returning anything.... please give the solution

@Manpreetkaurrao
Copy link

@codytwinton getting this issue....... as user just clicks done , without sharing the post it gives a callBack to success and in result field, its not returning anything.... please give an ETA for this issue

@Jignesh1805
Copy link

@royherma
Can you resolved dictionary empty after uploaded video ?

@robtimp
Copy link
Contributor

robtimp commented Jan 16, 2019

After changes to the Graph API last year, this is now the expected behavior. No further information is returned on success. We will update the SDK soon to reflect this.

@robtimp robtimp closed this as completed Jan 16, 2019
@Jignesh1805
Copy link

@robtimp How to solved this issue ? Which parameter return in success case ? We have need to postId .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something is broken or being fixed objc sdk This issue is associate with underlying Objective-C SDK
Projects
None yet
Development

No branches or pull requests

9 participants