iOS Share GIFs to Messenger using UIActivityViewController
Asked Answered
P

1

3

I am trying to share different type of images using UIActivityViewController to facebook messenger. I am facing no problem while sharing the images (.png), but I am not able to send gif images (.gif), it is giving error "Couldn't load content".

I am converting the image to data & then sending the data in array through UIActivityViewController.

Here, I am firing a notification with the details & extracting the gif path & then processing it.

NSDictionary *dictAsset = [notification userInfo];

NSData *imageData = [NSData dataWithContentsOfFile:dictAsset[@"path"]];

NSArray *imageToShare = [NSArray arrayWithObjects: imageData, [dictAsset objectForKey:@"assetName"], nil];

NSArray *arrAsset = imageToShare;

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:arrAsset applicationActivities:nil];

Has anyone faced same issue? or if anyone has a solution then please help me out.

Psychrometer answered 13/9, 2015 at 4:56 Comment(0)
O
1

iOS does not consider a GIF an image. You have to instead share it as a file:

NSURL *gifFile = [NSURL fileURLWithPath:@"funnyface.gif"];

NSArray *items = @[gifFile];

[[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
Oneidaoneil answered 10/6, 2016 at 17:19 Comment(1)
It works. This idea is good for me. I wasted a lot of time looking for this solution. Thank you so much.Izanami

© 2022 - 2024 — McMap. All rights reserved.