Send video in message to Facebook friend using FBSDKMessageDialog

289 views Asked by At

I want to send a video using my app to Facebook friend in Facebook messages.

I am using following code,

#pragma mark Social Network
- (void)fbSendVideoInMsg{

NSURL *videoURL = [NSURL URLWithString:[self.flyer getVideoAssetURL]];

//video url going fine, bellow is the value
//videoURL:assets-library://asset/asset.mov?id=BD3B188B-6D7E-436C-87D1-FA718282A5C1&ext=mov

FBSDKShareVideo *video = [[FBSDKShareVideo alloc] init];
video.videoURL = videoURL;

FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];
content.video = video;


FBSDKMessageDialog *shareFB = [[FBSDKMessageDialog alloc] init];
if ([shareFB canShow]) {
    shareFB.shareContent = content;

    shareFB.delegate = self;
    [shareFB show];
}
else{

    UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"can't show the share dialog box" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil ];

    [alert show];

  }
}

Its not loading video in Facebook message dialog

check this attachment

1

There are 1 answers

1
Muhammad Arqam Owais On

Use the following code. Hope this may help you.

NSString *filepath = [[NSBundle mainBundle] pathForResource:@"VideoName" ofType:@"VideoExtension"];
NSData *videoData = [NSData dataWithContentsOfFile:filepath];
[FBSDKMessengerSharer shareVideo:videoData withOptions:nil];