Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Photo Content Sharing" isn't working to Facebook share #2500

Open
5 tasks done
xujiali08 opened this issue Nov 11, 2024 · 1 comment
Open
5 tasks done

"Photo Content Sharing" isn't working to Facebook share #2500

xujiali08 opened this issue Nov 11, 2024 · 1 comment

Comments

@xujiali08
Copy link

xujiali08 commented Nov 11, 2024

Checklist before submitting a bug report

Xcode version

15.1

Facebook iOS SDK version

17.0.0

Dependency Manager

CocoaPods

SDK Framework

Share

Goals

Share photo to Facebook is also can be success in development environment.

Expected results

share photo to facebook and can find it in facebook

Actual results

After I clicked Share to Facebook, it jumped to the Facebook post page and previewed the sent content and image, but after clicking the post button, it came back to my app and didn't receive any SharingDelegate callback(didCompleteWithResults, didFailWithError or sharerDidCancel)

And then I went to my Facebook profile to look for it, I didn't find the content I just posted.

I confirmed that if I click on cancel posting I will get the sharerDidCancel callback.

Anything else, if I share content that is not an image but a URL, it is successful and will have the didCompleteWithResults callback.

Steps to reproduce

It's happen in a development environment every time, but if it's downloaded from the appstore, there is no problem

Code samples & details

extension ShareFacebookService {
    private func sharePhotoContent(_ viewModel: SocialShareFacebookViewModel) {
        guard let vc = UIApplication.shared.itKeyWindow?.visibleViewController else {
            self.completionHandlerBlock?(false, "viewController nil")
            return
        }
        
        if let images = viewModel.images, images.count > 0 {
            
            let photoContent = SharePhotoContent.init()
            var photos: [SharePhoto] = []
            
            for image in images {
                let photo = SharePhoto.init(image: image, isUserGenerated: true)
                photos.append(photo)
            }
            
            photoContent.photos = photos
            
            if let tag = viewModel.hashtag {
                photoContent.hashtag = Hashtag.init("#\(tag)")
            }
            
            if let contentURL = viewModel.contentUrl,
               let url = URL.init(string: contentURL) {
                photoContent.contentURL = url
            }
            let dialog = ShareDialog(viewController: vc, content: photoContent, delegate: self)
            dialog.mode = SocialShareFacebookService.isInstalled() ? .native : .automatic
            dialog.show()
        }else {
            self.completionHandlerBlock?(false, "image count is 0")
        }
    }
    private func shareLinkContent(_ viewModel: SocialShareFacebookViewModel) {
        guard let vc = UIApplication.shared.itKeyWindow?.visibleViewController else {
            self.completionHandlerBlock?(false, "viewController nil")
            return
        }
        let linkContent = ShareLinkContent.init()
        if let tag = viewModel.hashtag {
            linkContent.hashtag = Hashtag.init("#\(tag)")
        }
       
        if let contentURL = viewModel.contentUrl,
           let url = URL.init(string: contentURL) {
            linkContent.contentURL = url
        }
        
        if let quote = viewModel.quote {
            linkContent.quote = quote
        }
        let dialog = ShareDialog(viewController: vc, content: linkContent, delegate: self)
        dialog.mode = SocialShareFacebookService.isInstalled() ? .native : .automatic
        dialog.show()
    }
}

extension ShareFacebookService: SharingDelegate {
    func sharer(_ sharer: Sharing, didCompleteWithResults results: [String : Any]) {
        completionHandlerBlock?(true, nil)
    }
    
    func sharer(_ sharer: Sharing, didFailWithError error: Error) {
        completionHandlerBlock?(false, error.localizedDescription)
    }
    
    func sharerDidCancel(_ sharer: Sharing) {
        completionHandlerBlock?(false, nil)
    }
}
@jorgefrazaocosta
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants