简体   繁体   中英

SWIFT : How to Share multiple Photos or Video on Facebook using FBSDKShareKit?

I am using FBSDKShareKit to share video and images on facebook .

Here is the code :-

    if self.postObject.videoUrl.count > 0 {

            let content = ShareMediaContent()
            for VideoData in self.postObject.postedMedia {

                let video = ShareVideo.init(data: VideoData)
                content.media.append(video)
            }
            for thumb in self.postObject.postedVideoThumb {
                let photo = SharePhoto(image: thumb, userGenerated: true)
                content.media.append(photo)
            }
            let dialog = ShareDialog(fromViewController: self, content: content, delegate: self)
            print(dialog.canShow)
            dialog.show()

    }

But I am getting print(dialog.canShow) as false .

And the error I am getting in the " didFailWithError " delegate is:-

" Error Domain=com.facebook.sdk.share Code=2 "(null)" UserInfo={com.facebook.sdk:FBSDKErrorArgumentValueKey={length = 1727854, bytes = 0x00000014 66747970 71742020 00000000... acdda1ed 0ae116c8 }, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Cannot share video data., com.facebook.sdk:FBSDKErrorArgumentNameKey=data} "

Where am I doing wrong?

I had this error after I notice that the native facebook app must be installed.

But now with some configuration (Facebook Developer) is not necessary to have the Facebook app installed ( https://developers.facebook.com/docs/sharing/ios )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM