I want to share photo and some text from the app on Facebook. I used SLComposeViewController
class for sharing.
My problem is that when I tap on Facebook button a dialog box appears with image which I want to post but default text is not appearing in the device while in simulator it works perfectly fine. This code works perfectly for Twitter both in simulator and device. For more clarity I added code and an image
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result)
{
if (result == SLComposeViewControllerResultCancelled)
{
NSLog(@"Cancelled");
} else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Congratulations!" message:@"Photo is posted to facebook Wall." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler =myBlock;
str=[NSString stringWithFormat:@"Text to share"];
[controller setInitialText:str];
[controller addImage:savedImage];
[self presentViewController:controller animated:YES completion:Nil];
}