简体   繁体   English

Unity Facebook SDK:FB.IsLoggedIn / FB.ShareLink问题

[英]Unity Facebook SDK: FB.IsLoggedIn / FB.ShareLink issue

I'm trying to create my mobile app user to share my Facebook page and if they do, I give them an in-game item. 我试图创建我的移动应用程序用户以共享我的Facebook页面,如果可以,我给他们一个游戏内物品。 I'm using the example code provided by Facebook here: https://developers.facebook.com/docs/unity/examples 我在这里使用Facebook提供的示例代码: https : //developers.facebook.com/docs/unity/examples

The first issue is that FB.ShareLink doesn't comeback negative if the user cancels the sharing action. 第一个问题是,如果用户取消共享操作,FB.ShareLink不会恢复负值。 From what I've read, that's on purpose and it only works correctly if the user is logged in and my app is authorized. 根据我的阅读,这是有目的的,并且只有在用户登录并且我的应用已获得授权的情况下,它才能正常运行。 I tested it and that's true, if I use the login code to first login, it comes back as positive or negative correctly. 我已经测试过了,这是真的,如果我使用登录代码进行首次登录,它将正确返回为正数或负数。

The second issue that I'm having though is that FB.IsLoggedIn never comes back negative and I'm not sure how to properly check this because even though it comes back as true, my app is note authorized and FB.ShareLink doesn't return negative when canceled. 我遇到的第二个问题是FB.IsLoggedIn永远不会返回负数,并且我不确定如何正确检查此问题,因为即使返回为真,我的应用程序也已获得授权,而FB.ShareLink却没有取消时返回负数。 I start the Login issue and then I press the back arrow to cancel it but FB.IsLoggedIn still comes back as true. 我开始登录问题,然后按后退箭头将其取消,但FB.IsLoggedIn仍然返回true。

How can I just check if the app is authorized? 我如何才能查看该应用程序是否已授权? I'm guessing that's all I need to check before running the FB.ShareLink code. 我猜这就是在运行FB.ShareLink代码之前需要检查的所有内容。

Any ideas? 有任何想法吗? Thanks! 谢谢!

First, we try to login asking for the user's e-mail address. 首先,我们尝试登录以询问用户的电子邮件地址。

public void LogIntoFacebook() {
    List<string> perms = new List<string>() { "email" };
    FB.LogInWithReadPermissions(perms, OnLogin);
}

Then you can check to see if you got the e-mail address permission using 然后,您可以使用以下命令查看是否获得了电子邮件地址权限

AccessToken token = AccessToken.CurrentAccessToken;
if (token.Permissions.Contains("email")) { // do something }

If you do, then you move forward with the Facebook share. 如果您这样做,则可以继续使用Facebook分享。

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

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