2
votes

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.

1
If the account of FaceBook is not set in Setting.app, that's noral.Larme
So would people who are signed up to Facebook/Twitter not have a problem? it's only if you are not set up with those services that it will say it's not available?Phil
SLComposerViewController allows the user to post a message on FaceBook. But how can you tell which account to use? Remember, to use FaceBook, you have to create an account or login. Apple introduced since iOS6 the login from Settings.app, here the key to your issue. If the user is not logged, no FaceBook post.Larme
If you put that as an answer I'll accept it.Phil

1 Answers

2
votes

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.