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];
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.