Skip to main content

Overview

ShareLinkContent holds the data for a standard Facebook link share. Set at minimum the contentURL property, then pass the object to a ShareDialog. Module: FacebookShare
Declared in: ShareLinkContent.swift
Objective-C name: FBSDKShareLinkContent
Conforms to: SharingContent, SharingValidatable

Initializer

ShareLinkContent uses the default memberwise initializer. All properties have default values, so you can create an empty instance and set properties directly:
let content = ShareLinkContent()
content.contentURL = URL(string: "https://example.com/article")
content.quote = "An inspiring quote from the article."

Properties

contentURL
URL?
The URL to share. This is the primary required field for most share modes. The URL is checked for App Links meta tags to enable deep linking. Pass a valid https URL.
quote
String?
Optional text to display alongside the link. When specified, the quote appears with custom styling on top of the link preview.
hashtag
Hashtag?
An optional hashtag to include with the share. See Hashtag below.
pageID
String?
For shares into Messenger, this page ID maps the app to a page and attaches attribution to the share.
peopleIDs
[String]
An array of user IDs to tag in the post. Users must be taggable friends. Defaults to an empty array.
placeID
String?
The ID of a Facebook Place to tag with this content.
ref
String?
A value appended to the referrer URL when a person follows the shared link from their feed.
entityURI
String?
A URI identifying the resource at contentURL, used for resource-level linking.
isMusicAttachmentAllowed
Bool
When true, the SDK is allowed to attach background music to the share. Defaults to false.
shareUUID
String?
A unique identifier automatically generated for this share instance. Useful for analytics and tracking.

Hashtag

Hashtag represents a single hashtag to include with shared content. Objective-C name: FBSDKHashtag

Initializer

@objc(initWithString:)
public init(_ string: String)
string
String
The hashtag string, including the leading #. Example: "#SwiftDevelopment". Invalid hashtags (those not matching #\w+) are silently ignored when sharing.

Properties

stringRepresentation
String
The raw hashtag string as provided to the initializer.
isValid
Bool
true if the hashtag matches the pattern #\w+ (a # followed by one or more word characters).

Validation

When you pass a ShareLinkContent to a ShareDialog, the SDK validates the content before presenting the dialog. The contentURL, if provided, must be a valid network URL. If contentURL is nil, validation passes and the dialog may still be shown in some modes.

Usage example

import FacebookShare

let content = ShareLinkContent()
content.contentURL = URL(string: "https://developers.facebook.com/")
content.quote = "Build great things with Facebook."
content.hashtag = Hashtag("#FacebookSDK")

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

Build docs developers (and LLMs) love