Whatsapp not picking the video from the assetURL in UIActivityViewController

787 Views Asked by At

I am trying to upload a video to Whatsapp with an ALAsset URL, but it is loading the video when I share it using UIActivityViewController

ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc] init];

[assetLibrary assetForURL:self.videoURL resultBlock:^(ALAsset *asset) {
    NSArray *objectsToShare =  @[asset.defaultRepresentation.url];
    FrodoInstagramActivity *instagramActivity = [[FrodoInstagramActivity alloc] init];

    UIActivityViewController *activityVC = [[UIActivityViewController alloc] 
        initWithActivityItems:objectsToShare applicationActivities:@[instagramActivity]];
    [self presentViewController:activityVC animated:YES completion:nil];
} failureBlock:nil];
2

There are 2 best solutions below

5
Alvin Varghese On BEST ANSWER

Try this noh, "Movie" Your video which saved to local directory from video asset.

    NSString    * savePath  = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wam"];

savePath = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"m4v"];


    _documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
    _documentInteractionController.UTI = @"net.whatsapp.movie";
    _documentInteractionController.delegate = (id)self;

    [_documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:self.view animated: YES];

Save your asset locally, and get the local URL. Pass that URL path on the above code. Let's see.

Dont create each file locally for each video, just use the same file name for all videos and replace videos. And delete the video from local, after successfully uploaded. This might help.

1
Shubham Narang On

I have also face this problem with sharing the link on whatsapp.

In whatsapp sharing was restrit to number of characters.

Please share url and text with maximum 150 characters.

then say what happen.

happy coding :)