NatShare - Free Sharing API


Hi all! I am pleased to announce an API we decided to make public, open, free: NatShare. With NatShare, you can share images and videos, save to the camera roll, and retrieve a thumbnail for a video. NatShare has been made an independent project from NatCorder , our video recording API for Unity Engine.

NatShare Features Include:

  • Share images (Texture2D) using the native sharing UI
  • Share videos (using the video path) using the native sharing UI
  • Save images (Texture2D) to the camera roll
  • Save videos (using the video path) to the camera roll
  • Get a thumbnail for a video (using the video path)

The API is free and is hosted on the Asset Store and GitHub. Please feel free to open issues for bugs and feature requests:

NatShare on the Asset Store

NatShare on GitHub

Also, check out the release article.

NatShare will be added to the Asset Store soon. Thank you!

2 Likes

Hi. Coming back to my question about custom actions, the idea is to allow the player to choose what to do with a video. They can share on a social network, but might, on the other hand, to place it on the in game chat. We could make to share buttons in the game, but it feels much cleaner if we have a single share button, that shows the Native Share Sheet, but it includes, not only the supported share targets for that media type, but also some in game action, like for example share share in clan chat, or send to in game friendā€™s inbox.

Something like this:
http://pinkstone.co.uk/how-share-objects-using-your-own-uiactivity/
http://jayeshkawli.ghost.io/using-uiactivityviewcontroller-swift/

This use case is pretty specific to your application from the looks of it. This level of modification would have to be done by developers (you). You can fork the NatShare project and begin to modify it.

Will give it a go.

1 Like

Does this api allow for posting to social media, such as Facebook, Twitter, Instagram? I think those are the main ones my boss wants. Weā€™d like to be able to share images (taken with a different api) and video taken from NatCorder.

It seems there are some pretty common device-native solutions for this that I wouldnā€™t know where to begin to access. I presume they are device native because a lot of the Android apps and games seem to do these things in the exact same way.

Yes it does. It is indeed a native solution, so it is similar to other apps that provide similar functionality.

1 Like

Thanks! I got that implemented so far (was easy - or at least it seemed easyā€¦ Iā€™m building the first test now.)

Is there a way to be able to write the text of the post? I know a lot of games post messages to Facebook with things like coin requests or whatnot. Weā€™d like to use it to be able to add event hashtags for our Augmented Reality campaigns.

That sounds good. Currently there isnā€™t, but feel free to open a feature request issue on GitHub and weā€™ll review it.

Actually, I would suggest as well to remove the ā€œSharingā€ example code from NatCorder, here https://medium.com/@olokobayusuf/natcorder-unity-recording-made-easy-f0fdee0b5055, and replace with a redirect to NatShare stuff.

Iā€™ll wait it at Assets Store. Great job.

Nice catch! I have updated the post. I will let you know when we publish the API onto the Asset Store.

1 Like

Hi,

Using natshare, Iā€™m trying to get the thumbnail for the recorded video. Works perfect on Android, but iOS I get a weird result with the image becoming warped.

This is the code Iā€™m using:

void OnReplay (string path) {

NatShare.GetThumbnail(path, OnThumbnail);

}

void OnThumbnail (Texture2D thumbnail) {
rawimage.texture = thumbnail;
}

Am I messing something up here?

Can you share a screenshot? Also, what is the resolution of the returned thumbnail.

Hi,

I updated the NatCorder assets in my project and added the NatShare assets as well.

I am getting this error: ā€œā€¦/NatShare-API-1.0/WebGL/NatShare.js(6,6): UCE0001: ā€˜;ā€™ expected. Insert a semicolon at the end.ā€

This semicolon error appears for all 9 lines with ā€œconstā€. Is there something I need to do for these imported assets to make this not appear as an error?

Edit:
I assume I downloaded the right asset pack from ā€œGitHub - videokit-ai/natshare: Cross-platform social sharing for Unity Engine.ā€. I just brought it into my project normally, but perhaps I am missing something?

Can you share a screenshot of the error? You arenā€™t supposed to be receiving any error with the raw Javascript file (it shouldnā€™t be compiled by anything). What version of Unity are you using? Did you move files around after importing?

I am using Unity 2017.3.1.
I imported the files into a specific sub-folder, but didnā€™t move anything after it had been added to the project.

Also, I reimported it and this error shows up in addition: ā€œYou are trying to import an asset which contains a global game manager. This is not allowed.ā€


It seems that you downloaded the entire GitHub project. You should download the unitypackage instead. When you import it, do not move it into a sub-folder as it may break Unityā€™s plugin import schemes.

Attached screenshot. How do I check the resolution of the thumbnail? I havenā€™t set one manually.

3485929--277460--6A95CF09-8E9D-46B3-9FE6-A2CD091A31CF.jpg

To get the size of the image, simply log the returned textured width and height. I have a pretty good idea whatā€™s going on. Iā€™m working on a fix.

EDIT: I have made a fix for this issue. Grab NatShare 1.0f2.

For some reason now the app crashes on iOS as soon as recording is done. Iā€™ll test it today and see whatā€™s making it crash.

Can you share the logs and a screenshot of the call stack in Xcode? These should have a clue as to whatā€™s going on.