facebook / facebook/facebook-ios-sdk

Sharing preview in shareSheet mode not working

Open
#2,184 3 comments 0 reactions 0 assignees View on GitHub
bug needs-triage
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.2

### Facebook iOS SDK version

16

### Dependency Manager

SPM

### SDK Framework

Share

### Goals

Share link via ShareDialog with preview of the link and with FB app installed.

### Expected results

![IMG_0008](https://user-images.githubusercontent.com/39591134/221609239-741f6876-7211-4d17-bc31-2dbb27ca4d4a.PNG)

### Actual results

![IMG_21B3000CC7E0-1](https://user-images.githubusercontent.com/39591134/221609317-18347d84-6691-4da8-977e-522516175922.jpeg)

### Steps to reproduce

- use shareDialog
- set shareDialog mode to .shareSheet

### Code samples & details

```swift
override func prepare(withActivityItems activityItems: [Any]) {
guard let url = activityItems.first(where: { $0 is URL }) as? URL else {
self.shareContent = nil

return
}

let shareContent = ShareLinkContent()

shareContent.contentURL = url

self.shareContent = shareContent
}

override func perform() {
guard let shareContent = shareContent else {
logger.error(ReplicaCategory.sharing, "Error while sharing to Facebook: no content")

return
}

let shareDialog = ShareDialog(viewController: self.fromViewController, content: shareContent, delegate: self)

shareDialog.mode = .shareSheet

do {
try shareDialog.validate()
} catch {
logger.info(ReplicaCategory.sharing, "FacebookShareActivity - \(error.localizedDescription)")

}

shareDialog.show()
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.