I want to share image,url and text to facebook and I am not able to make it work on iOS9.Here is my code.
-(IBAction)shareOnFacebook:(id)sender{
UIButton *btn = (UIButton *)sender;
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:SHARING_QUOTE_D(self.dish.name, self.dish.restaurant.name)];
[controller addURL:[NSURL URLWithString:SHARING_URL]];
[controller addImage:self.dishImageView.image];
[self presentViewController:controller animated:YES completion:Nil];
if ([controller respondsToSelector:@selector(popoverPresentationController)])
{
UIPopoverPresentationController *presentationController = [controller popoverPresentationController];
presentationController.sourceView = btn; // if button or change to self.view.
}
}else{
[[[UIAlertView alloc] initWithTitle:@"Error Message" message:@"Please log into your Facebook account to post" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil] show];
}
}
You must use New Facebook SDK for sharing. Also you want Facebook app in the device. The iOS 9 will dismiss the SLComposeView and may be show you alert "....not supported..."
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.