简体   繁体   English

Facebook分享对话框在iOS中无法正常运行

[英]Facebook share dialog not quite working in iOS

I'm having a strange issue with the Facebook share dialog, and the documentation isn't much of a help. 我在Facebook共享对话框中遇到了一个奇怪的问题,该文档并没有太大帮助。 I'm using the dialog:andParams:andDelegate method to show it, and the first time, a login dialog shows up. 我正在使用dialog:andParams:andDelegate方法显示它,并且第一次出现一个登录对话框。 If I enter incorrect credentials, it just closes and doesn't tell me they were incorrect. 如果我输入的凭据不正确,它将关闭并且不会告诉我它们不正确。 If I enter correct credentials, it just closes too, without showing the share dialog. 如果我输入正确的凭据,它也将关闭,而不会显示共享对话框。 However, the next time I call the dialog:andParams:andDelegate: method, it goes straight to the share dialog, and it works fine. 但是,下次我调用dialog:andParams:andDelegate:方法时,它将直接进入共享对话框,并且可以正常工作。

My question is, why is the dialog being completely dismissed when I try to log in? 我的问题是,为什么在我尝试登录时对话框完全被关闭? I'm not doing anything with the session before displaying the dialog, because it seems like it should handle that itself, right? 在显示对话框之前,我没有对会话进行任何操作,因为似乎它应该自行处理,对吗? Or do I explicitly have to handle a logged out session, so it displays the dialog correctly? 还是我必须明确地处理注销的会话,才能正确显示对话框?

I do not know if that can be of any help but I use ShareKit to share stuff on social network (Facebook, Twitter, and some more). 我不知道这是否有帮助,但我使用ShareKit在社交网络(Facebook,Twitter等)上共享内容。 This API is really nice though. 这个API确实很棒。

You need to check if you're if you're logged in, if not call: 您需要检查是否已登录,如果没有登录,请致电:

[facebook_ authorize:permissions_];

and then listen to: 然后听:

-(void)fbDidLogin;

and save the auth tokens: 并保存身份验证令牌:

NSUserDefaults * prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:facebook_.accessToken forKey:@"AccessToken"];
[prefs setObject:facebook_.expirationDate forKey:@"ExpirationDate"];
[prefs synchronize];

And after the successful login call the share dialog: 成功登录后,调用共享对话框:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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