Skip to content

Media Attachment Guide

Media Attachment is a general purpose class used across GetSocial SDK to attach images, videos and GIFs.

Supported Formats and Size Limitations

Supported Formats Size Limitation
Images jpg, png, webp, cr2, tif, bmp 20 Mb
GIFs gif 20 Mb
Videos mp4, m4v, mkv, webm, mov, avi, wmv, mpg, flv, 3gp 20 Mb

If media size is bigger than the size limitation -it is ignored.

Attach Images

The image can be attached as a binary file, or as URL reference. Binary files are uploaded to GetSocial backend and optimized to serve back to the SDK.

1
2
3
4
Bitmap activityImage = ...; // Load image here
MediaAttachment imageAttachment = MediaAttachment.image(activityImage);

MediaAttachment urlAttachment = MediaAttachment.imageUrl("https://docs.getsocial.im/images/logo.png");
1
2
3
4
val activityImage : Bitmap = ... // Load image here
val imageAttachment = MediaAttachment.image(activityImage)

val urlAttachment = MediaAttachment.imageUrl("https://docs.getsocial.im/images/logo.png")
1
2
3
4
UIImage *postImage = ... ; // Load image here
MediaAttachment *imageAttachment = [GetSocialMediaAttachment image:postImage];

MediaAttachment *urlAttachment = [GetSocialMediaAttachment imageUrl:@"https://docs.getsocial.im/images/logo.png"];
1
2
3
4
let postImage: UIImage = ... // Load image here
let imageAttachment = GetSocialMediaAttachment.image(postImage);

let urlAttachment = GetSocialMediaAttachment.imageUrl("https://docs.getsocial.im/images/logo.png") 
1
2
3
4
Texture2D activityImage = ...;// Load image here
var imageAttachment = MediaAttachment.Image(activityImage);

MediaAttachment urlAttachment = MediaAttachment.ImageUrl("https://docs.getsocial.im/images/logo.png");
1
2
3
4
const imageUri = ...;// Set local image Uri
const imageAttachment = MediaAttachment.withLocalImageUri(imageUri);

const urlAttachment = MediaAttachment.withImageUrl('https://docs.getsocial.im/images/logo.png');

Attach GIFs

To attach GIF:

1
2
byte[] gifBinary = ... ; // Load gif as byte array
MediaAttachment gifAttachment = MediaAttachment.video(gifBinary);
1
2
val gifBinary = ... // Load gif as byte array
val gifAttachment = MediaAttachment.video(gifBinary)
1
2
NSData *gifBinary = ... ; // Load gif as NSData
GetSocialMediaAttachment *gifAttachment = [MediaAttachment video:gifBinary];
1
2
let gifBinary: Data = ... // Load gif as Data
let mediaAttachment = GetSocialMediaAttachment.video(binary)
1
2
const videoUri = ...;// Set local video Uri
const mediaAttachment = MediaAttachment.withLocalVideoUri(videoUri);

Unity

To simplify GIFs capturing on Unity we’ve created an open source GIF recording library. It integrates seemlessly with GetSocial SDK, but you can also use it standalone.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...

public GetSocialCapture capture;

...

// start recording if something interesting happens in the game
void RecordAction()
{
    capture.StartCapture();
}

// stop recording
void ActionFinished()
{
    capture.StopCapture();
    // generate gif
    capture.GenerateCapture(gifBinary =>
    {
        var gifAttachment = MediaAttachment.Video(gifBinary);
        // attach attachment to invite or activity post
    });
}

Attach Videos

Video can be attached as a binary file using the same method as for GIFs, or as URL reference. Binary files are uploaded to GetSocial backend and optimized to serve back to the SDK.

Give us your feedback! Was this article helpful?

😀 🙁