GIF Sharing

Currently, Social Gif plugin supports two social networks for GIFs sharing - Facebook and Twitter. New social networks will be added with the future updates.

It's super-simple to share the GIFs with Social Gif plugin. You have to provide one callback and make one method call. SA.GIF.Share APIs description is shown below

public static void Twitter (Recorder recorder, string message, System.Action<SA.Models.Result> callback = null)

Share Recorder content to Twitter with the message.

  • recorder - GIF Recorder.
  • message - Predefined text for sharing with the GIF
  • callback - (optional) Sharing callback action.
public static void Twitter (string filePath, string message, System.Action<SA.Models.Result> callback = null)

Share Recorder content to Twitter with the message.

  • filePath - GIF file path provided with SA.GIF.Recorder.OnFileSaved event callback.
  • message - Predefined text for sharing with the GIF
  • callback - (optional) Sharing callback action.
public static void Facebook (Recorder recorder, string message, System.Action<SA.Models.Result> callback = null)

Share Recorder content to Facebook with the message.

  • recorder - GIF Recorder.
  • message - Predefined text for sharing with the GIF
  • callback - (optional) Sharing callback action.
public static void Facebook (string filePath, string message, System.Action<SA.Models.Result> callback = null)

Share Recorder content to Facebook with the message.

  • filePath - GIF file path provided with SA.GIF.Recorder.OnFileSaved event callback.
  • message - Predefined text for sharing with the GIF
  • callback - (optional) Sharing callback action.

Let's make a Twitter sharing use-case. Code sample provided below:

private void Recorder_OnFileSaved (int id, string path) {
	SA.GIF.Share.Twitter(recorder, "message", TwitterSharingCallback);
}

private void TwitterSharingCallback(SA.Models.Result result) {
	if (result.IsSucceeded) {
		//Your logic in the case of successful sharing
	}
}

Please, pay your attention, that I make a call of SA.GIF.Share.Twitter method right inside the Recorder.OnFileSaved event callback. Anyway, you can call this method in any place you want.

You will get the SA.Models.Result object in the sharing callback. The most important properties of this object highlighted below:

namespace SA.Models {	
	public class Result  {
		/// <summary>
		/// Result Error Object. Can be null of result is succeeded
		/// </summary>
		public Error Error;

		/// <summary>
		/// True if is succeeded
		/// </summary>
		public bool IsSucceeded;
	}
}

The only one flag you have to check is the IsSucceeded flag. If it's True then sharing finished ok and you are ready to go with your other logic. Otherwise, you have to check the Error object for additional information of an issue.

Important: The text message provided with sharing should be ignored for Facebook. That's not the limitation of the plugin, that's the official Facebook policy. In the cases of native sharing (I mean without Facebook SDK integrated) the only user may provide the text with the message.

All the samples you can find in Assets/Plugins/StansAssets/Modules/SocialGif/xExamples/Demo scene. We use some free assets from Unity Asset Store from our demonstration, so, this sample requires minimum Unity v5.4.0f3 for a test. In older Unity versions you will just get an empty scene.