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:
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 textpayload.AddText("Sharing is caring");// Add imagepayload.AddImage(texture);// Add a media filepayload.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:
// Sharepayload.Commit();
NatShare supports reporting whether a given share action was successfully chosen by the user.
// Share and get success valuevar 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.