6

I'm trying to share a gif from my (unity) app, through the standard iOS sharing screen, to a social network.

Because of this question I first wrap the path to the gif in an NSURL before sending it to the UIActivityViewController:

NSURL *nsGifURL = [NSURL fileURLWithPath:nsGifPath];
NSArray *itemsToShare = @[nsMessage, nsGifURL];

// find the unity window:
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIActivityViewController *share = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
[window.rootViewController presentViewController:share animated:YES completion:nil];

This all compiles and runs without errors, but when I reach the other app, the image is static and not a gif.

How do I make apps like fb accept and display a gif on the other end?

EDIT: the nsGifPath definitely has the .gif extension

tenpn
  • 4,556
  • 5
  • 43
  • 63
  • I've also tried passing an NSData of the gif, to the same static-image result. The NSExtensionItem dumps some info about the object, and correctly identifies it as a com.compuserve.gif. – tenpn Apr 10 '18 at 16:36
  • check this similar questions having good answer https://stackoverflow.com/questions/26623931/how-to-share-an-gif-animated-images-in-ios – Ravi Panchal Apr 17 '18 at 05:16
  • read the data and try to use this function as extension for data, `var format: String { let array = [UInt8](self) let ext: String switch array[0] { case 0xFF: ext = "jpg" case 0x89: ext = "png" case 0x47: ext = "gif" case 0x4d: ext = "tiff" default: ext = "unknown" } return ext }` What do you get as result? – Marcel T Apr 18 '18 at 20:42
  • sorry, I'm not sure what "use as extension for data" means! – tenpn Apr 19 '18 at 16:33

1 Answers1

1

as this answer you have to consider separated ways for social networks

TWITTER : For share a GIF on twitter had to use twitter API and create a multipart request to achieve the goal and its working very well.

FACEBOOK : I did share some GIF on Facebook using FACEBOOKSHAREKIT , but i don't know why sometimes Gifs are animated, sometimes not.

INSTAGRAM : To share gif on Instagram had to convert GIFS to MP4 (or any other video formats accepted by Instagram) then save it into camera roll then share it , It is little twisted but its working very well.

WHATSAPP : It not supporting GIF at all.

To do all of this i couldn't use "UIActivityViewController" , so decided to create a custom share page. if anybody know something to add here , to help me and others please tell me (especially about Facebook). Thanks in advance

Arash Etemad
  • 1,827
  • 1
  • 13
  • 29
  • I think I'd rather not support gifs at all than integrate and support all these SDKs and workflows. Come on iOS, this works great on android... – tenpn May 02 '18 at 12:42