# Introduction

[Cross Platform Instagram Kit](http://u3d.as/1pMn) a true cross platform plugin for Unity which provides unique and unified way to access Instagram sharing features on mobile platforms.

Share images and video along with your own customised stickers on Instagram Platform.

![Share Image/Video along with custom stickers and lots more gifs from Giphy](https://241052107-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LVIBkhs8uMFufjZYdqg%2F-LVJ7v-J_pARYq5E3Cov%2F-LVJ7YShUo6UVjykbyXb%2FInstagramKitStory.png?alt=media\&token=9f33a67f-6810-4766-95d6-a518a6612ee8)

### Highlights

• Unified API design. \
• Auto-generates Android Manifest file. \
• Full source code is included.&#x20;

{% hint style="success" %}
Plugin supports mobile platforms iOS(9.0+) & Android (API 14+),&#x20;
{% endhint %}

### Features

• Share Stories on Instagram \
• Add your own customised Stickers \
• Share Picture on Instagram \
• Share Video on Instagram&#x20;

## [Support](https://join.skype.com/ln8JcMryHXpv)


# Namespace

For using plugin methods, you need to import the below namespace.

```csharp
using VoxelBusters.InstagramKit;
```

{% hint style="success" %}
We expose **InstagramKitManager** class to allow the access for plugin functionalities.
{% endhint %}


# Is Service Available

First check to be done before using the plugin features

## Check Service Availability

Check if Instagram Kit features can be usable. As the apps need instagram app on the running platform, its always good to check this before calling any of the other plugin methods.

```csharp
InstagramKitManager.IsAvailable();
```

Example

{% embed url="<https://gist.github.com/voxelbusters/3e3b6fcaaead9712a9e102f817f5c772#file-is-service-available>" %}
Example for check if service is available
{% endembed %}


# Image Sharing

Learn how to share an image

For sharing an image, you need to pass the path of the image to **StoryContent** instance

```csharp
StoryContent content = new StoryContent ("PATH_TO_IMAGE_FILE", false);
```

{% hint style="info" %}
&#x20;Passing **false** to StoryContent instance indicates the file passed is an **image**
{% endhint %}

Share the StoryContent on Instagram

```csharp
InstagramKitManager.Share(content, OnShareComplete); //OnShareComplete is callback method
```

{% hint style="info" %}
Image passed can be of JPG or PNG format.
{% endhint %}

Example

{% embed url="<https://gist.github.com/voxelbusters/bfa9bbb799909f4b2ab953ce9e41ad7d#file-shareimageoninstagram-cs>" %}


# Video Sharing

Learn how to share a video

For sharing a video, you need to pass the path of the video to **StoryContent** instance

```csharp
StoryContent content = new StoryContent ("PATH_TO_VIDEO_FILE", true);
```

{% hint style="info" %}
&#x20;Passing **true** to StoryContent instance indicates the file passed is a **video**
{% endhint %}

Share the StoryContent on Instagram

```csharp
InstagramKitManager.Share(content, OnShareComplete); //OnShareComplete is callback method
```

{% hint style="info" %}
Video passed can be of H.264 or H.265 or WebM formats.
{% endhint %}

Example

```csharp
using VoxelBusters.InstagramKit;

void ShareImage(string filePath)
{
    // Create Story Content Instance
    StoryContent content = new StoryContent(filePath, true);
    
    // Share
    InstagramKitManager.Share(content, OnShareComplete);
}

private void OnShareComplete(bool success, string error)
{
	string message  =  success ? "Successfully Shared" : "Failed to share " + error;
	Debug.Log(message);
}
```


# Add Stickers & Links

Learn how to add Stickers and Attachment Links

Stickers can be added to give extra information to share media. These can be mascots of your game, game title with your own custom font, etc.

Stickers can be added on top of image or video that is being shared.

### Create Sticker Instance

```csharp
Sticker sticker = new Sticker("PATH_TO_STICKER_IMAGE");
```

{% hint style="info" %}
Image passed can be of JPG or PNG format.
{% endhint %}

### Add Sticker to Story Content

```csharp
StoryContent content = new StoryContent("PATH_TO_IMAGE_FILE", false);
// StoryContent content = new StoryContent("PATH_TO_VIDEO_FILE", true);

content.SetSticker(sticker);// Pass sticker instance created above
```

## Add Attachment Link

Adding link to the sharing content lets users go to the target link along with the sharing content.

{% hint style="info" %}
Adding links feature to sharing content needs an approval from Instagram Team. [More Info here.](https://help.instagram.com/contact/605050879855497?fbclid=IwAR1xLRtNHLGxOFu77Rhi8dUOB7xv-lDp6CvwjgMOOaa-tG0BJK_XbMsDdB4)
{% endhint %}

```csharp
StoryContent content = new StoryContent("PATH_TO_IMAGE_FILE", false);
// StoryContent content = new StoryContent("PATH_TO_VIDEO_FILE", true);
​
content.SetAttachmentUrl("https://www.google.com");// Pass valid web url
```

## Example

```csharp
using VoxelBusters.InstagramKit;

private void Share(string contentFilePath, bool isVideoContent, string stickerPath, string attachmentUrl)
{
    StoryContent content = new StoryContent(contentFilePath, isVideoContent);

    // Create Sticker Instance
    Sticker sticker = new Sticker(stickerPath);
    
    // Set Sticker to the sharing content
    content.SetSticker(sticker);
    
    // Set Attachment Url
    content.SetAttachmentUrl(attachmentUrl);
            
    // Share the Content
    InstagramKitManager.Share(content, OnShareComplete);
}

private void OnShareComplete(bool success, string error)
{
	string message  =  success ? "Successfully Shared" : "Failed to share " + error;
	Debug.Log(message);
}
```


# Save Texture2D to Persistent Path

Utility function for saving texture to persistent path

{% embed url="<https://gist.github.com/voxelbusters/a8c603c7a4c9172ddb9c16b17ca023b9>" %}
Save Texture to Persistent Path
{% endembed %}

<br>


# Save Video to Persistent Path

Utility function for saving any file to persistent path

{% embed url="<https://gist.github.com/voxelbusters/df0a84ef7d890da0086b3b1e62e33f55>" %}
Save any file from local or web path to persistent path
{% endembed %}

<br>


