Share Button for iOS

With the Share Button you will allow people to share content to their Facebook timeline, to a friend's timeline or in a group.

Sharing on Mobile - Step by Step

The Share Button on mobile follows the same userflow like you know it from the Share Button for web: After tapping or clicking the button, the user will have options to add a message, customize the target audience and eventually confirm the share.

  1. Share Button: Will be displayed without share counter. User taps the Share Button, a new window will open (also known as fast-app-switch).
  2. Share Dialog: The window will show a post composer containing a preview of the shared link. If the user installed the Facebook app for iOS the share dialog will be served by the Facebook app otherwise by the Safari Browser. Via tap on the Share button the user will confirm the share and in the following come back to your application.

Adding the Share Button to your Application

1. General iOS Setup

2. Add Frameworks

3. Add Share button code

1. General iOS Setup

Complete the Getting Started Guide for Facebook iOS SDK before adding the Share button. The guide will include:

  • Setting up a Facebook application.
  • Downloading and installing the Facebook iOS SDK.
  • Adding the Facebook iOS SDK to your project.
Facebook SDK for iOS - Getting Started

2. Add Frameworks

To use the Share button in your view you need to add the Frameworks FBSDKCoreKit and FBSDKShareKit. You can find both in the Facebook iOS directory (~/Documents/FacebookSDK).

  1. Drag & drop the frameworks to your Frameworks folder in Xcode's project explorer.
  2. Add the following #import calls to the header of your view controller:
// For example in ViewController.m after `#import "ViewController.h"`
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKShareKit/FBSDKShareKit.h>

3. Add Share Button Code

You can add the Share button to your view like you would any other UIView. Create a new Share button FBSDKShareButton instance as shown in the code example shown below. Next assign an object of the type FBSDKShareLinkContent to the property shareContent. You must share a link URL (initWithContentURL), but all other values are optional.

//  ViewController.m
@implementation ViewController
- (void)viewDidLoad {
  [super viewDidLoad];
  FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
  content.contentURL = [NSURL
  FBSDKShareButton *shareButton = [[FBSDKShareButton alloc] init];
  shareButton.shareContent = content; =;
  [self.view addSubview:shareButton];

Customizing Shared Content

Generally there are two options to customize your shared content:

  1. Using Open Graph Tags.
  2. Adjust FBSDKShareLinkContent selectors

FBSDKShareLinkContent Selectors

Below we show which properties you can use and which values they must have. Please keep in mind that the post composer result will depend on the user's device configuration as well. E.g. the property placeID is currently only available for users having the Facebook app for iOS installed on their device.

Selector Description Type


URL for the content being shared.



Array of IDs for people to tag (NSString)



The ID for a place to tag with this content.



The ref for the content


Deprecated FBSDKShareLinkContent Selectors

As of April 18, 2017, the following parameters are no longer supported by Graph API versions 2.9 and higher. For versions 2.8 and lower, the parameters will continue working until July 17, 2017.

Selector Description Type


The link title



The description of the link



The network URL of an image


Usage example for FBSDKShareLinkContent Selectors

You can use the example posted below for testing the Share button in your application. User IDs used for peopleIDs must be friends of the current user. You can use the Graph API Explorer to quickly obtain friends IDs. If you do not know about friends permissions please refer to the Facebook Login permissions guide.

NSURL *contentURL = [[NSURL alloc] initWithString:
button.shareContent = [[FBSDKShareLinkContent alloc]
  initWithContentURL: contentURL
  peopleIDs: @[@"1561082740838259"]
  placeID: @"166793820034304"
  ref: @"myRefId"

Display Example

For a person the result of the example code shown above will look somewhat like this: