SavePayload

class NatSuite.Sharing.SavePayload

This payload is used to save items to the camera roll.

To use this payload on iOS, you must define the NSPhotoLibraryUsageDescription key in your Xcode project's Info.plist file.

To use this payload on Android, you must specify the WRITE_EXTERNAL_STORAGE permission in your app's manifest. You can do so in Player Settings.

Creating the Payload

/// <summary>
/// Create a save payload.
/// </summary>
/// <param name="album">Optional. Album in which items should be saved.</param>
SavePayload (string album = default);

The save payload can be optionally created to save items within a specific album in the camera roll. If the album does not already exist, it will be created.

Saving to a specific album will only work on Android Q or newer.

Adding Images

/// <summary>
/// Add an image to the payload from a pixel buffer.
/// The pixel buffer MUST have an RGBA8888 pixel layout.
/// </summary>
/// <param name="pixelBuffer">Pixel buffer containing image to add.</param>
/// <param name="width">Image width.</param>
/// <param name="height">Image height.</param>
void AddImage<T> (T[] pixelBuffer, int width, int height) where T : struct;
/// <summary>
/// Add an image to the payload.
/// Note that the image MUST be readable.
/// </summary>
/// <param name="image">Image to add.</param>
void AddImage (Texture2D image);

Refer to the Adding Images section of the ISharePayload interface for more information.

Adding Media Files

/// <summary>
/// Add a media file to the payload.
/// </summary>
/// <param name="path">Path to media file add.</param>
void AddMedia (string path);

Refer to the Adding Media Files section of the ISharePayload interface for more information.

Saving to the Camera Roll

/// <summary>
/// Commit the payload and return the success value.
/// </summary>
/// <returns>Whether the sharing action was successfully completed.</returns>
Task<bool> Commit ();

Refer to the Committing the Payload section of the ISharePayload interface for more information.