-2

I just want to add facebook functionality in my app. i want to add image on facebook through my app.

Is there any sample available for iOS6.

Monish Bansal
  • 509
  • 3
  • 15
  • possible duplicate of [Tutorial for SLComposeViewController sharing](http://stackoverflow.com/questions/12503287/tutorial-for-slcomposeviewcontroller-sharing) – Mick MacCallum Oct 06 '12 at 06:58

1 Answers1

7

Visit this official documentation, SLComposeViewController Class Reference.

Apple has created a social framework. SLComposeViewController is the controller which will handle all the request for social interaction.

if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
    SLComposeViewController *objSLComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
    SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result)
    {
        [objSLComposeViewController dismissViewControllerAnimated:YES completion:nil];
        switch(result)
        {
            case SLComposeViewControllerResultCancelled:
            default:
                break;
            case SLComposeViewControllerResultDone:
                break;
        }
    }
    [objSLComposeViewController addImage:yourImage];
    [objSLComposeViewController setInitialText:@"YourInitialText"];
    [objSLComposeViewController addURL:[NSURL URLWithString:@"YourURL"]];
    [objSLComposeViewController setCompletionHandler:completionHandler];
    [self presentModalviewController:objSLComposeViewController animated:YES completion:nil];
}

I hope this helps.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Janak Nirmal
  • 22,706
  • 18
  • 63
  • 99