Code Monkey home page Code Monkey logo

natshare-api's Introduction

NatShare API

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:

Native Sharing

To share an image, you can use the SharePayload:

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

You can share multiple items at once:

using (var payload = new SharePayload()) {
    payload.AddText("Happy Birthday!");
    payload.AddMedia("/path/to/some/media/file.mp4");
}

Most payloads support a callback argument. This callback will be invoked when the user has finished the sharing activity:

using (var payload = new SharePayload(
    completionHandler: () => {
        Debug.Log("User shared video!");
    }
))
    payload.AddMedia("/path/to/some/media/file.mp4")

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 = ...;
using (var payload = new SavePayload()) {
    payload.AddImage(image);
    payload.AddMedia("/path/to/some/media/file.gif");
}

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

  • On Android, NatShare requires API Level 18+
  • On iOS, NatShare requires iOS 9+

Quick Tips

Thank you very much!

natshare-api's People

Contributors

andreasherbig avatar furmankl avatar lanreolokoba avatar olokobayusuf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.