iOS Share GIF (animated image) not Working

It’s been almost 2 days that i’m looking to find a solution to my problem but i wasn’t successful , i want to share GIF (animated image) on Facebook, Twitter, Email, WhatsApp , using “UIActivityViewController”.

This is my code :

  • iphone facebook side menu using objective c
  • What is the delegate method that will called when closing an iPhone app by pressing (-) not the home button
  • Facebook iOS SDK 3.1: “Error: HTTP status code: 400”
  • Facebook IOS SDK Frictionless Requests
  • How to load animated GIF from photo library
  • Send image and text with OpenGraph FacebookSDK 4.4 in Swift
  • NSURL *imagePath = [NSURL URLWithString:@"http://img.ioscake.com/ios/sth.gif"];
    NSData *animatedGif = [NSData dataWithContentsOfURL:imagePath];
    
    NSArray *sharingItems = [NSArray arrayWithObjects: animatedGif,stringToShare, nil];
    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil];
    

    When i share in Email its animated and its working perfect , but in Twitter , Facebook , whatsApp Gifs are not animated and its like an image …
    I already read all Stack-overflow questions about the same problem Like this or this or this but its not working for me.

    3 Solutions Collect From Internet About “iOS Share GIF (animated image) not Working”

    So far base on days research found out that :

    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

    Encountered the similar problem and Googled a lot but still not a perfect solution, the best I came up is here:

    Use UIActivityItemProvider and extend – (id)item {} for different UIActivityType:

    Twitter: The default UIActivityViewController Twitter share doesn’t support it yet which it will “scale down” it as a still JPG. However somehow it works for GIF less than 100kb (tested in iOS 9) and I don’t know why. Therefore, I have to use SLRequest to upload the GIF as taught in here. When the SLRequest is done and return, dismiss the UIActivityViewController. The downside of that is no preview share sheet and users cannot type their own message anymore.

    Facebook: It’s actually much easier! Just upload the GIF to Giphy, then provide the Giphy URL to UIActivityViewController instead of the file contents, Facebook will recognize it and show the animated GIF

    - (id)item
    {    
        if ([self.activityType isEqualToString:UIActivityTypePostToFacebook]) {
            // Upload to Giphy
            ...
            return [NSURL URLWithString:giphyURL];
        }
        if ([self.activityType isEqualToString:UIActivityTypePostToTwitter]) {
            // Use SLRequest to share instead
            ...
            // Dismiss the UIActivityViewController (I am using Unity)
            [UnityGetGLViewController() dismissViewControllerAnimated:NO completion: NULL];
            return nil;
        }
    }
    

    full code is in my GitHub, I am actually a iOS newb so some experts please correct me and the code if possible

    // Share GIF File: WhatsApp

        NSURL *imageUrl =[self.ImageArray objectAtIndex:currentPhotoIndex];
        NSString *path=imageUrl.absoluteString;
        NSArray *strings = [path componentsSeparatedByString:@"/"];
        NSString *mygif=[strings objectAtIndex:strings.count-1];
    
        NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
        NSString *dataPath = [documentsPath stringByAppendingPathComponent:@"/MrHRamani"];
    
        NSString *filePath = [dataPath stringByAppendingPathComponent:mygif];
    
        NSURL *urll=[NSURL fileURLWithPath:filePath];
        NSLog(@"imag %@",imageUrl);
        self.documentationInteractionController.delegate = self;
        self.documentationInteractionController.UTI = @"net.whatsapp.image";
        self.documentationInteractionController = [self setupControllerWithURL:urll usingDelegate:self];
        [self.documentationInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];