Inherits from NSObject
Declared in FBSDKMessengerSharer.h

Overview

The FBSDKMessengerSharer is used to share media from apps into Messenger. The underlying mechanism used to share data between apps is UIPasteboard

  • FacebookAppID must be set in the your app’s Info.plist with the Facebook App Id
  • Any existing data in the system’s public pasteboard will get overwritten with the shared media
  • Once the data is shared in Messenger, the pasteboard with be cleared
  • The following strings need to be translated in your app: NSLocalizedString(@“Get Messenger”, @“Alert title telling a user they need to install Messenger”) NSLocalizedString(@“You are using an older version of Messenger that does not support this feature.”, @“Alert message when an old version of messenger is installed”) NSLocalizedString(@“Not Now”, @“Button label when user doesn’t want to install Messenger”) NSLocalizedString(@“Install”, @“Button label to install Messenger”) NSLocalizedString(@“Send”, @“Button label for sending a message”)

Class Methods

messengerPlatformCapabilities

This method checks the currently installed version of Messenger to see what SDK capabilities it has

+ (FBSDKMessengerPlatformCapability)messengerPlatformCapabilities

Discussion

Before sharing any media, first use this bitmask to check to see if it can be shared to Messenger

  • Warning: This method is deprecated as of iOS 9

  • Returns: bitmask of the Messenger capabilities

Declared In

FBSDKMessengerSharer.h

openMessenger

Call this method to open Messenger

+ (void)openMessenger

Declared In

FBSDKMessengerSharer.h

shareAnimatedGIF:withMetadata:withContext:

Call this method to open Messenger and share an animated GIF.

+ (void)shareAnimatedGIF:(NSData *)animatedGIFData withMetadata:(NSString *)metadata withContext:(FBSDKMessengerContext *)context

Discussion

  • Warning: use shareAnimatedGIF:withOptions: instead

  • Parameter animatedGIFData: The animated GIF to be shared in Messenger

  • Parameter metadata: Additional optional information to be sent to Messenger which is sent back to the user’s app when they reply to an attributed message. This may be nil.
  • Parameter context: The way the content is to be shared in Messenger. If nil, a standard share will take place.

If there is not an installed version of Messenger on the device that supports the share, an alert will be presented to notify the user.

Declared In

FBSDKMessengerSharer.h

shareAnimatedGIF:withOptions:

Call this method to open Messenger and share an animated GIF.

+ (void)shareAnimatedGIF:(NSData *)animatedGIFData withOptions:(FBSDKMessengerShareOptions *)options

Discussion

  • Parameter animatedGIFData: The animated GIF to be shared in Messenger
  • Parameter options: Additional optional parameters that affect the way the content is shared

If there is not an installed version of Messenger on the device that supports the share, an alert will be presented to notify the user.

Declared In

FBSDKMessengerSharer.h

shareAnimatedWebP:withMetadata:withContext:

Call this method to open Messenger and share an animated GIF.

+ (void)shareAnimatedWebP:(NSData *)animatedWebPData withMetadata:(NSString *)metadata withContext:(FBSDKMessengerContext *)context

Discussion

  • Warning: use shareAnimatedWebP:withOptions: instead

  • Parameter animatedWebPData: The animated WebP image to be shared in Messenger

  • Parameter metadata: Additional optional information to be sent to Messenger which is sent back to the user’s app when they reply to an attributed message. This may be nil.
  • Parameter context: The way the content is to be shared in Messenger. If nil, a standard share will take place.

If there is not an installed version of Messenger on the device that supports the share, an alert will be presented to notify the user.

Declared In

FBSDKMessengerSharer.h

shareAnimatedWebP:withOptions:

Call this method to open Messenger and share an animated GIF.

+ (void)shareAnimatedWebP:(NSData *)animatedWebPData withOptions:(FBSDKMessengerShareOptions *)options

Discussion

  • Parameter animatedWebPData: The animated WebP image to be shared in Messenger
  • Parameter options: Additional optional parameters that affect the way the content is shared

If there is not an installed version of Messenger on the device that supports the share, an alert will be presented to notify the user.

Declared In

FBSDKMessengerSharer.h

shareAudio:withMetadata:withContext:

Call this method to open Messenger and share an audio file.

+ (void)shareAudio:(NSData *)audioData withMetadata:(NSString *)metadata withContext:(FBSDKMessengerContext *)context

Discussion

  • Warning: use shareAudio:withOptions: instead

Note that there’s no way to send an AVAsset between apps, so you may need to serialize your AVAsset to a file, and get an NSData representation of the video via [NSData dataWithContentsOfFile:filepath];

  • Parameter audioData: The audio to be shared in Messenger
  • Parameter metadata: Additional optional information to be sent to Messenger

If there is not an installed version of Messenger on the device that supports the share, an alert will be presented to notify the user.

Declared In

FBSDKMessengerSharer.h

shareAudio:withOptions:

Call this method to open Messenger and share an audio file.

+ (void)shareAudio:(NSData *)audioData withOptions:(FBSDKMessengerShareOptions *)options

Discussion

Note that there’s no way to send an AVAsset between apps, so you may need to serialize your AVAsset to a file, and get an NSData representation of the video via [NSData dataWithContentsOfFile:filepath];

  • Parameter audioData: The audio to be shared in Messenger
  • Parameter options: Additional optional parameters that affect the way the content is shared

If there is not an installed version of Messenger on the device that supports the share, an alert will be presented to notify the user.

Declared In

FBSDKMessengerSharer.h

shareImage:withMetadata:withContext:

Call this method to open Messenger and share an image.

+ (void)shareImage:(UIImage *)image withMetadata:(NSString *)metadata withContext:(FBSDKMessengerContext *)context

Discussion

  • Warning: use shareImage:withOptions: instead

  • Parameter image: The image to be shared in Messenger

  • Parameter metadata: Additional optional information to be sent to Messenger which is sent back to the user’s app when they reply to an attributed message. This may be nil.
  • Parameter context: The way the content is to be shared in Messenger. If nil, a standard share will take place.

If there is not an installed version of Messenger on the device that supports the share, an alert will be presented to notify the user.

Declared In

FBSDKMessengerSharer.h

shareImage:withOptions:

Call this method to open Messenger and share an image.

+ (void)shareImage:(UIImage *)image withOptions:(FBSDKMessengerShareOptions *)options

Discussion

  • Parameter image: The image to be shared in Messenger
  • Parameter options: Additional optional parameters that affect the way the content is shared

If there is not an installed version of Messenger on the device that supports the share, an alert will be presented to notify the user.

Declared In

FBSDKMessengerSharer.h

shareVideo:withMetadata:withContext:

Call this method to open Messenger and share a video.

+ (void)shareVideo:(NSData *)videoData withMetadata:(NSString *)metadata withContext:(FBSDKMessengerContext *)context

Discussion

  • Warning: use shareVideo:withOptions: instead

Note that there’s no way to send an AVAsset between apps, so you may need to serialize your AVAsset to a file, and get an NSData representation of the video via [NSData dataWithContentsOfFile:filepath];

  • Parameter videoData: The image to be shared in Messenger
  • Parameter metadata: Additional optional information to be sent to Messenger which is sent back to the user’s app when they reply to an attributed message. This may be nil.
  • Parameter context: The way the content is to be shared in Messenger. If nil, a standard share will take place.

If there is not an installed version of Messenger on the device that supports the share, an alert will be presented to notify the user.

Declared In

FBSDKMessengerSharer.h

shareVideo:withOptions:

Call this method to open Messenger and share a video.

+ (void)shareVideo:(NSData *)videoData withOptions:(FBSDKMessengerShareOptions *)options

Discussion

Note that there’s no way to send an AVAsset between apps, so you may need to serialize your AVAsset to a file, and get an NSData representation of the video via [NSData dataWithContentsOfFile:filepath];

  • Parameter videoData: The image to be shared in Messenger
  • Parameter options: Additional optional parameters that affect the way the content is shared

If there is not an installed version of Messenger on the device that supports the share, an alert will be presented to notify the user.

Declared In

FBSDKMessengerSharer.h