Prince Kumar Sharma
Prince Kumar Sharma

Reputation: 12641

Can we share Video on FB using SLComposeViewController?

I have used SLComposeViewController to share image and url's as follows:

  SLComposeViewController *fbComposer =
  [SLComposeViewController
   composeViewControllerForServiceType:SLServiceTypeFacebook];

  if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
  {
   SLComposeViewControllerCompletionHandler __block completionHandler=
   ^(SLComposeViewControllerResult result){

    [fbComposer dismissViewControllerAnimated:YES completion:nil];

    switch(result){
     case SLComposeViewControllerResultCancelled:
     default:
     {
      NSLog(@"Cancelled.....");
     }
      break;
     case SLComposeViewControllerResultDone:
     {
      NSLog(@"Posted....");
      UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Sent"
                                                       message:nil
                                                      delegate:nil
                                             cancelButtonTitle:@"Dismiss"
                                             otherButtonTitles: nil];
      [alert show];
     }
      break;
    }};
    NSString *message=@"posting to FB test";
   [fbComposer setInitialText:message];
   [fbComposer addImage:[UIImage imageNamed:@"2.jpg"]];
   [fbComposer addURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=GoZ2Be2zLq8"]];
   [fbComposer setCompletionHandler:completionHandler];
   [self presentViewController:fbComposer animated:YES completion:nil];
  }

Can we also able to share video file using SLComposeViewController. Thanks in advance.

Upvotes: 2

Views: 3874

Answers (2)

Vishnu Kumar. S
Vishnu Kumar. S

Reputation: 1837

If you want to share a video url to the Facebook, you can use the following code.

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:string];  
[controller addImage:image];
[controller addURL:[NSURL URLWithString:URLString]];
[self.controller presentViewController:controller animated:YES completion:Nil];
[controller setCompletionHandler:^(SLComposeViewControllerResult result){
            switch (result) {
                case SLComposeViewControllerResultCancelled:
                    // Cancelled
                    break;

                case SLComposeViewControllerResultDone:
                   // Success
                    break;

                default:
                    break;
            }
        }];

Upvotes: 0

Vishal
Vishal

Reputation: 8256

No, we can't share video file using SLComposeViewController. For sending video file we have to

use Fb Graph API. Refer this link & use it you can easily be able to send video file to fb:

http://developers.facebook.com/blog/post/2011/08/04/how-to--use-the-graph-api-to-upload-a-video--ios/

Upvotes: 4

Related Questions