How to share NSData or phasset video using Facebook iOS SDK 4.0 FBSDKShareDialog

I noticed you can share NSData video to facebook messenger simply:

NSData *videoData = [NSData dataWithContentsOfURL:localVideoUrl];
[FBSDKMessengerSharer shareVideo:videoData withOptions:options];

But I’m having difficulties doing the same when sharing to facebook feed
using local video file or phasset.

  • How to gain root privileges for iOS app?
  • Which iOS class/code returns the magnetic North?
  • Detecting taps on attributed text in a UITextView while the keyboard is showing
  • iOS: App is not asking user's permission while installing the app. getting kCLAuthorizationStatusNotDetermined every time - Objective-c & Swift
  • AVPlayerViewController using audio-only AVPlayer
  • How do I restrict my app for only iPhone 6 and 6 Plus?
  • FBSDKShareVideo *video = [FBSDKShareVideo videoWithVideoURL:localVideoUrl];
    FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];
    [content setVideo: video];
    [FBSDKShareDialog showFromViewController:nil withContent:content delegate:self];

    com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Only asset file URLs are allowed for the native dialog

    How would I go about having similar nice app-switching behavior using phasset video?


    2 Solutions Collect From Internet About “How to share NSData or phasset video using Facebook iOS SDK 4.0 FBSDKShareDialog”

    With the new Facebook SDK 4.0, videos must be passed as assets URL. You have to copy your local video path to Assets Library and use that generated URL to share on Facebook.

    Step 1:

    NSURL *videoURL=[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"IMG_1007" ofType:@"mp4"]];
    [self saveToCameraRoll:videoURL];

    Step 2:

    - (void)saveToCameraRoll:(NSURL *)srcURL
        NSLog(@"srcURL: %@", srcURL);
        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        ALAssetsLibraryWriteVideoCompletionBlock videoWriteCompletionBlock =
        ^(NSURL *newURL, NSError *error) {
            if (error) {
                NSLog( @"Error writing image with metadata to Photo Library: %@", error );
            } else {
                NSLog( @"Wrote image with metadata to Photo Library %@", newURL.absoluteString);
                url_new  = newURL;
        if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:srcURL])
            [library writeVideoAtPathToSavedPhotosAlbum:srcURL

    Step 3:

    FBSDKShareDialog *shareDialog = [[FBSDKShareDialog alloc] init];    
    NSURL *videoURL = url_new;
    FBSDKShareVideo *video = [[FBSDKShareVideo alloc] init];
    video.videoURL = videoURL;
    FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init]; = video;
    shareDialog.shareContent = content;
    shareDialog.delegate = self;
    [shareDialog show];

    If you have any other query please let me know.


    Please check: 1)The videos must be less than 12MB in size. 2)People who share should have Facebook for iOS client installed, version 26.0 or higher.

    You should use the below line:

    NSURL *movieUrl = [info objectForKey:UIImagePickerControllerReferenceURL];

    instead of

    NSURL *movieUrl = [info objectForKey:UIImagePickerControllerMediaURL];