Skip to main content

Overview

ShareVideoContent holds a single ShareVideo to share as a Facebook video post. You can supply the video as raw Data, a PHAsset, or a file URL. Module: FacebookShare
Declared in: ShareVideoContent.swift
Objective-C name: FBSDKShareVideoContent
Conforms to: SharingContent, SharingValidatable

Initializer

ShareVideoContent uses the default initializer. Create an instance and set the video property:
let content = ShareVideoContent()
content.video = ShareVideo(videoURL: localFileURL)

Properties

video
ShareVideo
The video to share. This is required. Validation fails if no source is set on the ShareVideo object.
contentURL
URL?
An optional URL associated with the content for App Links.
hashtag
Hashtag?
An optional hashtag to include with the share.
peopleIDs
[String]
User IDs to tag in the post. Defaults to an empty array.
placeID
String?
The ID of a Facebook Place to tag with this content.
pageID
String?
For Messenger shares, this page ID maps the app to a page and attaches attribution.
shareUUID
String?
A unique identifier automatically generated for this share instance.

ShareVideo

ShareVideo represents a single video. Only one source may be active at a time: data, videoAsset, or videoURL. Objective-C name: FBSDKShareVideo

Initializers

init(data:previewPhoto:)

public convenience init(
    data: Data,
    previewPhoto: SharePhoto? = nil
)
data
Data
Raw video data.
previewPhoto
SharePhoto?
An optional thumbnail image to show before the video plays.

init(videoAsset:previewPhoto:)

public convenience init(
    videoAsset: PHAsset,
    previewPhoto: SharePhoto? = nil
)
videoAsset
PHAsset
A PHAsset from the Photos library. Must refer to a video.
previewPhoto
SharePhoto?
An optional thumbnail image.

init(videoURL:previewPhoto:)

public convenience init(
    videoURL: URL,
    previewPhoto: SharePhoto? = nil
)
videoURL
URL
A local file URL or an assets-library URL pointing to the video on device.
previewPhoto
SharePhoto?
An optional thumbnail image.

Properties

data
Data?
Raw video data. Setting this clears videoAsset and videoURL.
videoAsset
PHAsset?
A PHAsset from the Photos library. Setting this clears data and videoURL.
videoURL
URL?
A file URL to the video. Setting this clears data and videoAsset. Supports file:// and assets-library:// schemes.
previewPhoto
SharePhoto?
An optional SharePhoto used as the video thumbnail. Setting the source (data, videoAsset, or videoURL) automatically clears this property.

Usage example

import FacebookShare

// Share a video from a local file
let videoURL = Bundle.main.url(forResource: "promo", withExtension: "mp4")!
let previewImage = SharePhoto(image: thumbnailImage, isUserGenerated: false)
let video = ShareVideo(videoURL: videoURL, previewPhoto: previewImage)

let content = ShareVideoContent()
content.video = video

ShareDialog.show(
    viewController: self,
    content: content,
    delegate: self
)

// Share a video from the Photos library
let asset: PHAsset = selectedVideoAsset
let phVideo = ShareVideo(videoAsset: asset)
let phContent = ShareVideoContent()
phContent.video = phVideo

Build docs developers (and LLMs) love