Socket
Socket
Sign inDemoInstall

api.natsuite.natshare

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    api.natsuite.natshare

Cross-platform social sharing for Unity Engine.


Version published
Maintainers
1
Created

Readme

Source

NatShare

NatShare is a lightweight, easy-to-use native sharing API for Unity Engine. NatShare supports sharing text, images (using a Texture2D) and media files (using a string path). Currently, you can save media to the camera roll and open the native sharing UI.

Setup Instructions

Add the following items to your Unity project's Packages/manifest.json:

{
  "scopedRegistries": [
    {
      "name": "NatSuite Framework",
      "url": "https://registry.npmjs.com",
      "scopes": ["api.natsuite"]
    }
  ],
  "dependencies": {
    "api.natsuite.natshare": "1.2.5"
  }
}

Native Sharing

To share an image, you can use the SharePayload:

Texture2D image = ...;
var payload = new SharePayload()
payload.AddImage(image);
payload.Commit();

You can share multiple items at once:

new SharePayload()
    .AddText("Happy Birthday!")
    .AddImage(image)
    .AddMedia("/path/to/some/media/file.mp4")
    .Commit();

The ISharePayload.Commit function returns a task which when completed, returns a bool indicating whether the sharing operation was successful:

async void ShareVideo () {
    var success = await new SharePayload().AddMedia("/path/to/some/media/file.mp4").Commit();
    Debug.Log($"Successfully shared items: {success}");
}    

Saving to the Camera Roll

You can save images or media files to the camera roll with the SavePayload:

// Save a texture and a media file to the camera roll
Texture2D image = ...;
var payload = new SavePayload();
payload.AddImage(image);
payload.AddMedia("/path/to/some/media/file.gif");
payload.Commit();

iOS Instructions

After building an Xcode project from Unity, add the following keys to the Info.plist file with a good description:

  • NSPhotoLibraryUsageDescription
  • NSPhotoLibraryAddUsageDescription

Requirements

  • Unity 2019.3+
  • Android API level 22+
  • iOS 9+

Quick Tips

  • To discuss, report an issue, or request a feature, visit Unity forums or GitHub
  • Check out the online documentation
  • Contact me at yusuf@natsuite.io

Thank you very much!

Keywords

FAQs

Last updated on 20 Sep 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc