Ian Vink
Ian Vink

Reputation: 68770

MonoTouch: Facebook integration with iOS API

I'm writing a simple "FaceBook-This" function to open up a post for the user based on content from my app. What am I missing to get the FaceBook UI up?

  public static void FacebookThis (string text)
  {
     if (SLComposeViewController.IsAvailable (SLServiceKind.Facebook)) {
        var service = SLComposeViewController.FromService(SLServiceKind.Facebook);
        service.SetInitialText(text);
     }
  }

Upvotes: 1

Views: 319

Answers (1)

David Clarke
David Clarke

Reputation: 13266

You're just missing the PresentViewController() call, and then dismiss it in the completion handler:

public static void FacebookThis (string text)
{
    if (SLComposeViewController.IsAvailable (SLServiceKind.Facebook)) {
        var service = SLComposeViewController.FromService(SLServiceKind.Facebook);
        service.SetInitialText(text);
        service.CompletionHandler += (result) => {
            DismissViewController(true, null);
        }
        PresentViewController(service, true, null);
    }
}

Upvotes: 1

Related Questions