Question

I'm using the code snippet which was posted on my previous question, Simple way to add Facebook/Twitter share to app?

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
    SLComposeViewController *slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

    [slComposeViewController setInitialText:@"Your text"];
    [slComposeViewController addImage:[UIImage imageNamed:@"NameOfImage"]];
    [self presentViewController:slComposeViewController animated:YES completion:nil];
} else {
    //Show alert or in some way handle the fact that the device does not support this //feature
    NSLog(@"Facebook not available");
}

But when I run it on the device and in the simulator all I'm getting is "Facebook not available", what could I be doing wrong?

I've looked at the available tutorials, and I've included the libraries that are required, so I'm not sure what else I'm doing wrong.

Was it helpful?

Solution

In Settings.app/Facebook, you need to set up an account. SLComposeViewController only allows you to posts on FaceBook if you have an account. That's normal behavior, that's how FaceBook works: No account, nothing to do there.
Since iOS6, you can enter your account in iOS allowing apps to use this account with some of the iOS framework without importing the Facebook SDK. Of course, you have little options with the Social.framework, and if you want to do more, like timelines, etc. you'll have to use the FaceBook SDK.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top