facebook / facebook-ios-sdk

Used to integrate the Facebook Platform with your iOS & tvOS apps.
https://developers.facebook.com/docs/ios
Other
7.75k stars 3.52k forks source link

Sharing preview in shareSheet mode not working #2184

Open devcros4 opened 1 year ago

devcros4 commented 1 year ago

Checklist before submitting a bug report

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

Actual results

IMG_21B3000CC7E0-1

Steps to reproduce

Code samples & details

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()
    }
GertSallaerts commented 1 month ago

We are experiencing the same results, but it only happens when you share a link that's "never" been shared on Facebook. If you either share the link to Facebook on web first or run it through the Sharing Debugger tool before opening the share sheet the preview shows fine.

This makes it sound like the issue is not in the SDK but in the Facebook app (or more specifically the ios sharing extension) itself.