I am trying to implement the native Share dialog from Facebook in a sample application.
Seem to have some problem in doing so.
Things I have done so far:
- (IBAction)btn_facebook:(id)sender {
[self performSelector:@selector(fb_func) withObject:nil afterDelay:0.0];
}
-(void)fb_func
{
// if the session is closed, then we open it here, and establish a handler for state changes
[FBSession openActiveSessionWithReadPermissions:nil allowLoginUI:YES completionHandler:^(FBSession *session,FBSessionState state, NSError *error)
{
if (error)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
else if(session.isOpen)
{
NSString *str_link = @"";
NSLog(@"%@",str_link);
NSDictionary *params = @{
@"name" :@"name",
@"caption" : @"Description",
@"description" :@"test",
@"picture" : PostimageToPintresrAndFacebook,
@"link" : @"url",
};
// Invoke the dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
NSLog(@"Error publishing story.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
NSLog(@"User canceled story publishing.");
} else {
NSLog(@"Story published.");
}
}}];
}
}];
return;
}