Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook dialog login issue

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?

like image 789
Vsevolod Kukhelny Avatar asked Nov 05 '22 06:11

Vsevolod Kukhelny


1 Answers

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.

like image 176
ikuramedia Avatar answered Nov 09 '22 09:11

ikuramedia