facebookarchive / facebook-swift-sdk

Integrate your iOS apps in Swift with Facebook Platform.
https://developers.facebook.com/docs/swift
Other
1.51k stars 336 forks source link

ShareDialog is not working in Facebook's Swift SDK. Callbacks do not trigger #534

Closed AraibKarim closed 5 years ago

AraibKarim commented 5 years ago

Checklist

Environment

Describe your dev environment here, giving as many details as possible. If you have them, make sure to include:

Goals

1) Share a link through ShareDailog via facebook swift SDK and get callbacks if the share was successful or if the share failed.

Expected Results

ShareDailog (after sharing a post on facebook) should return to our app and generate a call back

Actual Results

No callbacks were generated. Methods like "sharer: didCompleteWithResults" are not being called.

Steps to Reproduce

  1. Integrate Swift Facebook SDK (latest)
  2. Implement ShareDailog
  3. do actions on return callbacks.

Code Samples & Details

Note: Remember to format your code for readability:


 func showShareDialog<C: SharingContent>(_ content: C, mode: ShareDialog.Mode = ShareDialog.Mode.automatic) {
        let dialog = ShareDialog(fromViewController: self, content: content, delegate: self)
        dialog.mode = mode

        dialog.show()
}

 func sharer(_ sharer: Sharing, didCompleteWithResults results: [String: Any]) {

        let title = "Share Success"
        let message = "Thank You"
        let alertController = UIAlertController.init(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
        self.present(alertController, animated: true, completion: nil)

    }

    func sharer(_ sharer: Sharing, didFailWithError error: Error) {

        let title = "Share Failed"
        let message = "Something went wrong. Please try again"
        let alertController = UIAlertController.init(title: title, message: message, preferredStyle: UIAlertController.Style.actionSheet)
        self.present(alertController, animated: true, completion: nil)
    }

    func sharerDidCancel(_ sharer: Sharing) {

        let title = "Share Cancelled"
        let message = "Share on Facebook was Cancelled"
        let alertController = UIAlertController.init(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
        self.present(alertController, animated: true, completion: nil)
    }

AppDelegate

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
 ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
  return true
  }

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

Additional comment

AraibKarim commented 5 years ago

is there any solution to the above problem? or some alternative way to integrate Facebook Share Dialog with Swift?

joesus commented 5 years ago

Thank you for opening an issue. While this may be a legitimate issue, we will no longer be contributing to this repository. This repository will be archived on November 1st, 2019 as mentioned in the README.md. Please check the migration guide for instructions on how transition to the new code base which contains a more recent set of bug fixes. If you are still seeing the issue at that point please open an new issue in the iOS SDK.