Social Share Composer
Plugin supports sharing to three social networks.
  • Facebook
  • Twitter
  • Whats App
When creating an instance of SocialShareComposer you can pass the SocialShareComposerType for sharing to specific social network.
You can check the availability of a composer by calling IsComposerAvailable.
1
bool isFacebookAvailable = SocialShareComposer.IsComposerAvailable(SocialShareComposerType.Facebook);
Copied!
The above returns true if the app is installed on the device and ready to accept any sharing.
On some social networks, it's not possible to share multiple data at same time. For example sharing url and image may lead to share only one of those.

Facebook

As per facebook policy, it's not possible to share a pre-filled text.

Share screenshot

1
SocialShareComposer composer = SocialShareComposer.CreateInstance(SocialShareComposerType.Facebook);
2
composer.AddScreenshot();
3
composer.SetCompletionCallback((result, error) => {
4
Debug.Log("Social Share Composer was closed. Result code: " + result.ResultCode);
5
});
6
composer.Show();
Copied!

Share image

1
Texture2D texture = Resources.Load<Texture2D>("texture name");
2
3
SocialShareComposer composer = SocialShareComposer.CreateInstance(SocialShareComposerType.Facebook);
4
composer.AddImage(texture);
5
composer.SetCompletionCallback((result, error) => {
6
Debug.Log("Social Share Composer was closed. Result code: " + result.ResultCode);
7
});
8
composer.Show();
Copied!

Share URL

1
SocialShareComposer composer = SocialShareComposer.CreateInstance(SocialShareComposerType.Facebook);
2
composer.AddURL(URLString.URLWithPath("https://www.google.com"));
3
composer.SetCompletionCallback((result, error) => {
4
Debug.Log("Social Share Composer was closed. Result code: " + result.ResultCode);
5
});
6
composer.Show();
Copied!

Twitter

Share text

1
SocialShareComposer composer = SocialShareComposer.CreateInstance(SocialShareComposerType.Twitter);
2
composer.SetText("Share text");
3
composer.SetCompletionCallback((result, error) => {
4
Debug.Log("Social Share Composer was closed. Result code: " + result.ResultCode);
5
});
6
composer.Show();
Copied!

Share screenshot

1
SocialShareComposer composer = SocialShareComposer.CreateInstance(SocialShareComposerType.Twitter);
2
composer.AddScreenshot();
3
composer.SetCompletionCallback((result, error) => {
4
Debug.Log("Social Share Composer was closed. Result code: " + result.ResultCode);
5
});
6
composer.Show();
Copied!

Share image

1
Texture2D texture = Resources.Load<Texture2D>("texture name");
2
3
SocialShareComposer composer = new SocialShareComposer(SocialShareComposerType.Twitter);
4
composer.AddImage(texture);
5
composer.SetCompletionCallback((result, error) => {
6
Debug.Log("Social Share Composer was closed. Result code: " + result.ResultCode);
7
});
8
composer.Show();
Copied!

Share URL

1
SocialShareComposer composer = SocialShareComposer.CreateInstance(SocialShareComposerType.Twitter);
2
composer.AddURL(URLString.URLWithPath("https://www.google.com"));
3
composer.SetCompletionCallback((result, error) => {
4
Debug.Log("Social Share Composer was closed. Result code: " + result.ResultCode);
5
});
6
composer.Show();
Copied!

Whats App

Share text

1
SocialShareComposer composer = SocialShareComposer.CreateInstance(SocialShareComposerType.WhatsApp);
2
composer.SetText("Share text");
3
composer.SetCompletionCallback((result, error) => {
4
Debug.Log("Social Share Composer was closed. Result code: " + result.ResultCode);
5
});
6
composer.Show();
Copied!

Share text with screenshot

1
SocialShareComposer composer = SocialShareComposer.CreateInstance(SocialShareComposerType.WhatsApp);
2
composer.SetText("Share text");
3
composer.AddScreenshot();
4
composer.SetCompletionCallback((result, error) => {
5
Debug.Log("Social Share Composer was closed. Result code: " + result.ResultCode);
6
});
7
composer.Show();
Copied!
On iOS, sharing both text and screenshot are not possible. Only either one of those is possible on WhatsApp.

Share screenshot

1
SocialShareComposer composer = SocialShareComposer.CreateInstance(SocialShareComposerType.WhatsApp);
2
composer.AddScreenshot();
3
composer.SetCompletionCallback((result, error) => {
4
Debug.Log("Social Share Composer was closed. Result code: " + result.ResultCode);
5
});
6
composer.Show();
Copied!

Share image

1
Texture2D texture = Resources.Load<Texture2D>("texture name");
2
3
SocialShareComposer composer = SocialShareComposer.CreateInstance(SocialShareComposerType.WhatsApp);
4
composer.AddImage(texture);
5
composer.SetCompletionCallback((result, error) => {
6
Debug.Log("Social Share Composer was closed. Result code: " + result.ResultCode);
7
});
8
composer.Show();
Copied!

Share URL

1
SocialShareComposer composer = SocialShareComposer.CreateInstance(SocialShareComposerType.WhatsApp);
2
composer.AddURL(URLString.URLWithPath("https://www.google.com"));
3
composer.SetCompletionCallback((result, error) => {
4
Debug.Log("Social Share Composer was closed. Result code: " + result.ResultCode);
5
});
6
composer.Show();
Copied!
Last modified 11mo ago