I Am trying to just post an image with small description on Facebook through my iOS6 app. I Am using SLComposeViewController for this:
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
NSString *shareText = @"This is my art using MyApp";
[mySLComposerSheet setInitialText:shareText];
**[mySLComposerSheet addImage:self.mainImage.image];**
[mySLComposerSheet addURL:[NSURL URLWithString:@"https://itunes.apple.com/in/app/myApp/id665759410?mt=8"]];
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
switch (result) {
case SLComposeViewControllerResultCancelled: {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"Could not post on your wall" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert show];
NSLog(@"Post Canceled");
break;
}
case SLComposeViewControllerResultDone:
{
NSLog(@"Post Sucessful");
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Success" message:@"Posted succesfully on your wall" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert show];
break;
}
default:
break;
}
}];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}
This is currently the code I use for posting to Facebook. But this doesn't show up the image during the post, instead there is a blank safari logo in place of it. I don't understand what's going wrong here. Can anybody help?