Social Sharing

Sharing is Caring

NatShare is primarily built around social sharing. The SharePayload exposes this functionality, allowing you to share content to other apps using the native sharing UI. To begin, create a payload:

// Create a share payload
using var payload = new SharePayload();

The payload acts as a write-only collection of items to be shared. Shareable items include plain text, images (Texture2D objects), and media files (referenced by their file paths).

// Add text
payload.AddText("Sharing is caring");
// Add image
payload.AddImage(texture);
// Add a media file
payload.AddMedia("/path/to/video.mp4");

Once all the items have been added to the payload, it can be committed to the operating system for sharing:

// Share
payload.Share();

NatShare supports reporting the app ID of the receiving app that was chosen by the user:

// Share and get receiving app
var receiverAppId = await payload.Share();
Debug.Log($"User shared to app: {receiverAppId}");

Last updated