Overview
ShareDialog is the main entry point for sharing content on Facebook. It supports multiple presentation modes—native app, iOS share sheet, browser, and web—and chooses the best available mode automatically when you use .automatic.
Module: FacebookShareDeclared in:
ShareDialog.swiftObjective-C name:
FBSDKShareDialog
Supported content types
| Content type | Class |
|---|---|
| Links | ShareLinkContent |
| Photos | SharePhotoContent |
| Videos | ShareVideoContent |
| Camera effects | ShareCameraEffectContent |
| Mixed media | ShareMediaContent |
Initializer
init(viewController:content:delegate:)
The view controller from which to present the dialog. Pass
nil to use the topmost view controller.The content to share. Must be one of the supported content types listed above.
A weak delegate that receives share completion, cancellation, and failure callbacks.
Static factory methods
ShareDialog.dialog(viewController:content:delegate:)
Creates but does not show a ShareDialog.
ShareDialog.show(viewController:content:delegate:)
Creates and immediately shows a ShareDialog.
Properties
The view controller from which the dialog is presented. Weak reference.
Controls how the dialog is presented. Defaults to
.automatic. See ShareDialog.Mode.The content to be shared. You can update this before calling
show().The object receiving share lifecycle events. Weak reference.
When
true, the dialog fails if it detects invalid data in the share content. When false, the dialog is still shown but the misconfigured data is omitted. Defaults to false.true if the dialog can be shown given the current mode, content, and device capabilities. Check this before calling show() if you want to avoid a failed attempt.Methods
show()
Presents the share dialog.
true if the dialog was displayed successfully, false if validation failed.ShareDialog.Mode enum
| Case | Description |
|---|---|
.automatic | Selects the best available mode automatically (default). |
.native | Presents the dialog inside the main Facebook app. Requires the Facebook app to be installed. |
.shareSheet | Uses the iOS integrated share sheet (SLComposeViewController). Requires the Facebook app to be installed. |
.browser | Opens the share dialog in Safari. |
.web | (Deprecated) Opens in a WKWebView inside your app. |
.feedBrowser | (Deprecated) Opens the feed dialog in Safari. |
.feedWeb | (Deprecated) Opens the feed dialog in a WKWebView. |
SharingDelegate protocol
Implement this protocol to receive the result of a share attempt.
Objective-C name: FBSDKSharingDelegate
sharer(_:didCompleteWithResults:)
Called when sharing completes without error or cancellation.
The sharer that completed.
A dictionary of results from the share dialog. May be empty.