FBSDKMessengerSharer
A more recent version of this class is available. Check out the latest version.

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

Discussion:
  • 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")
Superclass:NSObject
Declared in:FBSDKMessengerSharer.h
Class Methods
messengerPlatformCapabilities

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

+ (FBSDKMessengerPlatformCapability) messengerPlatformCapabilities __attribute__((deprecated("This is deprecated as of iOS 9. If you use this, you must configure your plist as described in https://developers.facebook.com/docs/ios/ios9")));
Discussion:

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

shareAnimatedGIF:withMetadata:withContext:

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

ParameterDescription
animatedGIFData

The animated GIF to be shared in Messenger

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.

context

The way the content is to be shared in Messenger. If nil, a standard share will take place.

+ (void)
shareAnimatedGIF: (NSData *)animatedGIFData
withMetadata: (NSString *)metadata
withContext: (FBSDKMessengerContext *)context
__attribute__((deprecated("use use shareAnimatedGIF:withOptions: instead")))NS_EXTENSION_UNAVAILABLE_IOS("");
Discussion:

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.

shareAnimatedGIF:withOptions:

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

ParameterDescription
animatedGIFData

The animated GIF to be shared in Messenger

options

Additional optional parameters that affect the way the content is shared

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

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.

shareAnimatedWebP:withMetadata:withContext:

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

ParameterDescription
animatedWebPData

The animated WebP image to be shared in Messenger

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.

context

The way the content is to be shared in Messenger. If nil, a standard share will take place.

+ (void)
shareAnimatedWebP: (NSData *)animatedWebPData
withMetadata: (NSString *)metadata
withContext: (FBSDKMessengerContext *)context
__attribute__((deprecated("use use shareAnimatedWebP:withOptions: instead")))NS_EXTENSION_UNAVAILABLE_IOS("");
Discussion:

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.

shareAnimatedWebP:withOptions:

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

ParameterDescription
animatedWebPData

The animated WebP image to be shared in Messenger

options

Additional optional parameters that affect the way the content is shared

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

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.

shareAudio:withMetadata:withContext:

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

ParameterDescription
audioData

The audio to be shared in Messenger

metadata

Additional optional information to be sent to Messenger

+ (void)
shareAudio: (NSData *)audioData
withMetadata: (NSString *)metadata
withContext: (FBSDKMessengerContext *)context
__attribute__((deprecated("use use shareAudio:withOptions: instead")))NS_EXTENSION_UNAVAILABLE_IOS("");
Discussion:

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.

shareAudio:withOptions:

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

ParameterDescription
audioData

The audio to be shared in Messenger

options

Additional optional parameters that affect the way the content is shared

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

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.

shareImage:withMetadata:withContext:

Call this method to open Messenger and share an image.

ParameterDescription
image

The image to be shared in Messenger

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.

context

The way the content is to be shared in Messenger. If nil, a standard share will take place.

+ (void)
shareImage: (UIImage *)image
withMetadata: (NSString *)metadata
withContext: (FBSDKMessengerContext *)context
__attribute__((deprecated("use use shareImage:withOptions: instead")))NS_EXTENSION_UNAVAILABLE_IOS("");
Discussion:

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.

shareImage:withOptions:

Call this method to open Messenger and share an image.

ParameterDescription
image

The image to be shared in Messenger

options

Additional optional parameters that affect the way the content is shared

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

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.

shareVideo:withMetadata:withContext:

Call this method to open Messenger and share a video.

ParameterDescription
videoData

The image to be shared in Messenger

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.

context

The way the content is to be shared in Messenger. If nil, a standard share will take place.

+ (void)
shareVideo: (NSData *)videoData
withMetadata: (NSString *)metadata
withContext: (FBSDKMessengerContext *)context
__attribute__((deprecated("use use shareVideo:withOptions: instead")))NS_EXTENSION_UNAVAILABLE_IOS("");
Discussion:

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.

shareVideo:withOptions:

Call this method to open Messenger and share a video.

ParameterDescription
videoData

The image to be shared in Messenger

options

Additional optional parameters that affect the way the content is shared

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

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.

Typedefs
NS_OPTION(NSUInteger,

Used to test the platform capabilities the currently installed Messenger version has

typedef NS_OPTIONS(NSUInteger, FBSDKMessengerPlatformCapability) {
FBSDKMessengerPlatformCapabilityNone = 0, FBSDKMessengerPlatformCapabilityOpen =
1 << 0, FBSDKMessengerPlatformCapabilityImage = 1 << 1, FBSDKMessengerPlatformCapabilityAnimatedGIF =
1 << 2, FBSDKMessengerPlatformCapabilityAnimatedWebP = 1 << 3, FBSDKMessengerPlatformCapabilityVideo =
1 << 4, FBSDKMessengerPlatformCapabilityAudio = 1 << 5, FBSDKMessengerPlatformCapabilityRenderAsSticker =
1 << 6,
};
Discussion:

FBSDKMessengerPlatformCapability)

NS_OPTIONS

Used to test the platform capabilities the currently installed Messenger version has

typedef NS_OPTIONS(NSUInteger, FBSDKMessengerPlatformCapability) {
FBSDKMessengerPlatformCapabilityNone = 0, FBSDKMessengerPlatformCapabilityOpen =
1 << 0, FBSDKMessengerPlatformCapabilityImage = 1 << 1, FBSDKMessengerPlatformCapabilityAnimatedGIF =
1 << 2, FBSDKMessengerPlatformCapabilityAnimatedWebP = 1 << 3, FBSDKMessengerPlatformCapabilityVideo =
1 << 4, FBSDKMessengerPlatformCapabilityAudio = 1 << 5, FBSDKMessengerPlatformCapabilityRenderAsSticker =
1 << 6,
};
Discussion:

FBSDKMessengerPlatformCapability)