5
votes

I use Facebook dialog to post on the wall in such way

[facebook dialog:@"feed" andParams:params andDelegate:self];

If user was not logged in before dialog, login window is appeared in dialog. That's OK,but when user press Log in dialog is dismissed and user must to call dialog again,and after all post my message on his wall. That's pretty weird to force user call dialog twice,so can anyone help me with this problem?

3
I have the exact same problem which I couldn't find the answer to. You'd think the Facebook SDK when it goes to the login screen would automatically go back to where it was meant to be after logging in. I tried issuing Login first then post, however if you cancel the login you also have to dismiss the post dialog. - Darren

3 Answers

2
votes

The easiest way to fix this is to store your params in an ivar. Then when FBConnect calls your delegate with fbDidLogin then you can automatically re-issue the dialog:andParams:andDelegate call.

The longer and more correct solution, is that you need to separate out the authorisation and posting steps. You can store the fb.accessToken and expiry date in NSUserDefaults, and then recall them the first time you try to access FBConnect. If the expiry date has passed, then you make the call to authorize:delegate to get a new access key. Once the fbLogin is complete, then you post the dialog to the user to continue.

Alternatively, you can not reinvent the wheel, and check out ShareKit http://getsharekit.com/ for a more complete solution.

0
votes

Try this code given in that link with that answer also,instead of your "HACBOOK EXAMPLE" code given by facebook... Facebook API dialog page showing error in second time and after that .Dont forget to give appId in the top of your viewController..

0
votes

The best solution I found for this problem is call [facebook dialog:@"feed" andParams:params andDelegate:self] one more time in (void)dialog:(FBDialog*)dialog didFailWithError:(NSError *)error. It's called after you logged in,but dialog is dismissed.