Socket
Socket
Sign inDemoInstall

ai.natml.natshare

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ai.natml.natshare

Cross-platform social sharing for Unity Engine.


Version published
Weekly downloads
64
increased by8.47%
Maintainers
1
Created
Weekly downloads
 

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": "NatML",
      "url": "https://registry.npmjs.com",
      "scopes": ["ai.natml"]
    }
  ],
  "dependencies": {
    "ai.natml.natshare": "1.3.1"
  }
}

Native Sharing

To share media, you can use the SharePayload:

// Say we want to share an image
Texture2D image = ...;
// Create a share payload
using var payload = new SharePayload();
// Add the image to the payload
payload.AddImage(image);
// Share!
await payload.Share();

Saving to the Camera Roll

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

// Say we want to save an image to the camera roll
Texture2D image = ...;
// Create a save payload
using var payload = new SavePayload();
// Add different items
payload.AddImage(image);
payload.AddMedia("/path/to/some/media/animated.gif");
// Save to the camera roll!
await payload.Save();

Platform Notes

iOS

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

  • NSPhotoLibraryUsageDescription
  • NSPhotoLibraryAddUsageDescription

Android

When building an Android project with Proguard stripping, make sure to add a keep rule for NatShare:

-keep class ai.natml.** { *; }

Requirements

  • Unity 2021.2+

Supported Platforms

  • Android API level 24+
  • iOS 14+
  • WebGL:
    • Chrome 91+
    • Firefox 90+
    • Safari 13+

Resources

  • Join the NatML community on Discord.
  • See the NatShare documentation.
  • See more NatML projects on GitHub.
  • Read the NatML blog.
  • Discuss NatShare on Unity Forums.
  • Contact us at hi@natml.ai.

Thank you very much!

Keywords

FAQs

Last updated on 09 Jul 2023

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