facebook / facebook/facebook-ios-sdk
When I set the SharingDelegate to a custom object, it doesn't response anymore.It looks like the delegate must be the fromviewcontroller
- Dominant language
- Swift
- Stars
- 8.1k
- Forks
- 3.7k
- PR merge metrics
- No merged PRs in 30d
Description
### Checklist before submitting a bug report
- [X] I've updated to the latest released version of the SDK
- [X] I've searched for existing [GitHub issues](https://github.com/facebook/facebook-ios-sdk/issues)
- [X] I've looked for existing answers on [Stack Overflow](https://facebook.stackoverflow.com), the [Facebook Developer Community Forum](https://developers.facebook.com/community/) and the [Facebook Developers Group](https://www.facebook.com/groups/fbdevelopers)
- [X] I've read the [Code of Conduct](https://github.com/facebook/facebook-ios-sdk/blob/main/CODE_OF_CONDUCT.md)
- [X] This issue is not security related and can safely be disclosed publicly on GitHub
### Xcode version
14.3.1
### Facebook iOS SDK version
16.1.3
### Dependency Manager
Prebuilt Binaries
### SDK Framework
Share
### Goals
I want to set a mediator as the sharingdelegate, not only the fromviewcontroller.
### Expected results
Set an object which comply with FBSDKSharingDelegate as sharingdelegate, and work fine.
### Actual results
Only set fromviewcontroller as the sharingdelegate, it works fine.when I create a mediator, and set the mediator as the sharingdelegate, I can't get any notify when I cancel a share or share successfully.
### Steps to reproduce
_No response_
### Code samples & details
```swift
import FacebookShare
import UIKit
final class ShareViewController: UITableViewController {
@IBAction func shareLink() {
guard let url = URL(string: "https://newsroom.fb.com/") else {
preconditionFailure("URL is invalid")
}
let content = ShareLinkContent()
content.contentURL = url
content.quote = "facebook test quote"
content.hashtag = Hashtag("#bestSharingSampleEver")
let sharemanager = ShareManager()
let dialog = sharemanager.dialog(withContent: content, from: self)
dialog.show()
}
}
class ShareManager: SharingDelegate {
func dialog(withContent content: SharingContent, from controller: UIViewController) -> ShareDialog {
let dialog = ShareDialog(
viewController: controller,
content: content,
delegate: self)
dialog.mode = .web
return dialog
}
func sharer(_ sharer: Sharing, didCompleteWithResults results: [String : Any]) {
print(results)
}
func sharer(_ sharer: Sharing, didFailWithError error: Error) {
print(error)
}
func sharerDidCancel(_ sharer: Sharing) {
print("Cancelled")
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.