I am using the following code to post something on Facebook.
- (IBAction)post:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
mySocialComposer = [[SLComposeViewController alloc]init];
mySocialComposer = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySocialComposer setInitialText:@"Hellooooooo World"];
[mySocialComposer addImage:[UIImage imageNamed:@"image.jpg"]];
[self presentViewController:mySocialComposer animated:YES completion:nil];
[mySocialComposer setCompletionHandler:^(SLComposeViewControllerResult result){
NSString *outout = [[NSString alloc] init];
switch (result) {
case SLComposeViewControllerResultCancelled:
outout = @"Post Cancled";
break;
case SLComposeViewControllerResultDone:
outout = @"Post Successfull";
default:
break;
}
UIAlertView *myalertView = [[UIAlertView alloc]initWithTitle:@"FaceBook"
message:outout delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[myalertView show];
}];
}
}
I am using the above method to post on Facebook from iOS app.If I do post including an Image and some text it successfully post ed on Facebook. But when I try to post on Facebook without the image just text for that purpose i comment out the following line.
[mySocialComposer addImage:[UIImage imageNamed:@"image.jpg"]];
And while doing that i got an error alert that This post cannot be sent because connection to Facebook lost. Is there any way that i can post on Facebook without image . Thanks in advance.