Search code examples
objective-cvideofacebook-ios-sdk

Uploading video using Facebook SDK and iOS9, what am I doing wrong?


I'm not sure what I'm doing wrong here and hope someone can point me in the right direction as the code is failing silently without any error output...I've checked every thread here and have tried all suggested solutions to no avail.

I'm trying to upload a video to facebook using the latest SDK for ios and the code below--I've checked the permissions--they are correct, I can upload images, post messages, etc

I've also tried the parameter @"video.mov" as well as the graphPath @"{userID}/video}"

It looks like the FBSDKGraphRequest never starts. I've checked the NSData by writing it to a local mov file and playing it with no problems.

Any help is appreciated, thanks

     NSMutableData * movieData=[[NSMutableData alloc]init];
    [manager requestDataForAssetResource:asset[1] options:nil dataReceivedHandler:^(NSData * _Nonnull data) {
        [movieData appendData:data];
    } completionHandler:^(NSError * _Nullable error) {

        if (error == nil) {



            NSDictionary *stuff = @{
                                     @"source": movieData,
                                     @"description":@"testing",
                                      @"contentType":@"video/quicktime",
                                     };

            /* make the API call */

       if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"publish_actions"]) {

           NSLog(@"starting connection");
            FBSDKGraphRequest *connection = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me/videos" parameters:stuff HTTPMethod:@"POST"];


            [connection startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

                if (!error) {

                    NSLog(@"Video uploaded %@",result);

                } else {

                    NSLog(@"Video uploaded failed %@",error.userInfo);

                }

            }];

Solution

  • I got it to work by pulling the post function out of the completionHandler..for some reason the request doesn't execute there.