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
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
// Add a media file
Once all the items have been added to the payload, it can be committed to the operating system for sharing:
// Share
NatShare supports reporting whether a given share action was successfully chosen by the user.
// Share and get success value
var success = await payload.Commit();
Note that this only reports whether the user chose a share action, not whether they actually completed the action. The user can cancel after they have chosen one.
Android will never report a failure if the user does not choose a target application.
Copy link