简体   繁体   中英

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?

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.

尝试使用该答案中给出的代码,而不是你的Facebook提供的“HACBOOK EXAMPLE”代码... Facebook API对话框页面在第二次和之后显示错误。不要忘记在viewController的顶部提供appId ..

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM