Add Extra Content(Stickers & Links)
Learn how to add Stickers, Caption Text & Links to the content being shared
For any sharing content (image/video/live camera), you can add three kinds of extra data.
  • Stickers
Stickers allow to show additional content to attribute the existing sharing content. Only one sticker is allowed. A still sticker must be a PNG 1MB or smaller. An animated sticker must be a GIF or WebP (preferred) 1MB or smaller.
  • Caption Text
This is the caption given to the sharing content once after sharing. Captions are limited to 250 characters.
  • Attachment URL
URL that can be attached to the sharing content. Usually, you can link your game or attach a deep link to your game content. The attachment URL must be a properly formatted URL in string format.

Add Sticker

Create Sticker

Create SnapchatSticker Instance and set its properties. Properties include position of sticker, rotation and size in pixels.
1
private SnapchatSticker CreateSticker()
2
{
3
SnapchatSticker sticker = null;
4
sticker = new SnapchatSticker(Application.persistentDataPath + "/" + SharingStickerName);
5
6
// Set Position in normalised screen coordinates
7
sticker.SetPosition(0.5f, 0.5f);
8
9
// Set rotation in degrees
10
sticker.SetRotation(-45f);
11
12
// Set size for the sticker in pixels
13
sticker.SetSize(Screen.width * 0.3f, Screen.height * 0.3f);
14
15
return sticker;
16
}
Copied!

Set Sticker to content

Set SnapchatSticker instance created above to SnapchatContent Instance.
1
SnapchatContent content;
2
....
3
....
4
SnapchatSticker sticker = CreateSticker();// Refer code above
5
content.SetSticker(sticker);
6
....
7
SnapchatKitManager.Share(content, OnShareComplete);
Copied!

Add Caption Text

This is the message displayed over the sharing content (Image/Video/LiveCamera). Pass the text to SnapchatContent instance.
1
content.SetCaptionText("My awesome game!");
Copied!

Add Attachment Url

Pass url which can be opened once the user shares on snapchat. Usually this can be the url of your game so the snapchat users can find it on app store.
1
content.SetAttachmentUrl("https://www.google.com");
Copied!

Example

1
using VoxelBusters.SnapchatKit;
2
3
void ShareToSnapchat(string contentFilePath, bool isVideo)
4
{
5
SnapchatContent content;
6
if(isVideo)
7
{
8
content = new SnapchatContent(eSnapchatContentType.Video);
9
}
10
else
11
{
12
content = new SnapchatContent(eSnapchatContentType.Photo);
13
}
14
15
// Set content data
16
content.SetContentData(contentFilePath);
17
18
// Set sticker
19
SnapchatSticker sticker = CreateSticker();
20
content.SetSticker(sticker);
21
22
// Set Caption Text
23
content.SetCaptionText("My Aweseome Game");
24
25
// Set Attachment Url
26
content.SetAttachmentUrl("https://www.play.google.com");
27
28
// Share
29
SnapchatKitManager.Share(content, OnShareComplete);
30
}
31
32
private SnapchatSticker CreateSticker()
33
{
34
SnapchatSticker sticker = null;
35
sticker = new SnapchatSticker(Application.persistentDataPath + "/" + SharingStickerName);
36
37
// Set Position in normalised screen coordinates
38
sticker.SetPosition(0.5f, 0.5f);
39
40
// Set rotation in degrees
41
sticker.SetRotation(-45f);
42
43
// Set size for the sticker in pixels
44
sticker.SetSize(Screen.width * 0.3f, Screen.height * 0.3f);
45
46
return sticker;
47
}
48
49
private void OnShareComplete(bool success, string error)
50
{
51
string message = success ? "Successfully Shared" : "Failed to share " + error;
52
Debug.Log(message);
53
}
Copied!
Last modified 2yr ago