如何退出 Facebook 并切换用户?
How to Logout from Facebook and switch a user?
我在我的应用程序上用用户登录了 facebook。
稍后当我在我的 Facebook 应用程序和浏览器上手动注销该用户时,
(FB.IsLoggedIn) 仍然 returns 正确。
出于某种原因,旧的配置文件已保存,我无法使用新用户登录
这是我的代码:
public void FacebookLogin()
{
if (FB.IsLoggedIn)
FB.LogOut(); //it doesn't work, user is still logged in
var permissions = new List<string>() {"email"};
FB.LogInWithReadPermissions(permissions); //trying to login a new user, but the last user is still logged in
将您的 FacebookLogin
函数更改为协程函数。通过这样做,您可以检查用户是否已登录,注销用户然后等待每一帧直到 FB.IsLoggedIn
是 false
,然后您才能登录另一个用户。还要在等待中添加一个计时器,这样当 FB.IsLoggedIn
在 x
时间内永远不会 false
时,函数不会继续到 运行 而是显示一些错误并退出.
public IEnumerator FacebookLogin()
{
//5 seconds loggout time
float waitTimeOut = 5f;
//Log out if loggedin
if (FB.IsLoggedIn)
FB.LogOut(); //it doesn't work, user is still logged in
//Wait until logout is done. Also add a timeout to the wait so that it doesnt wait forever
float timer = 0;
while (FB.IsLoggedIn)
{
if (timer > waitTimeOut)
{
Debug.LogError("Failed to log out within " + waitTimeOut + " seconds");
yield break;
}
timer += Time.deltaTime;
yield return null;
}
Debug.Log("Successfully logged out. Now logging another user in");
var permissions = new List<string>() { "email" };
FB.LogInWithReadPermissions(permissions); //trying
}
如果您仍然对此有疑问,您需要使用此答案中的代码在 facebook-sdk-for-unity Github 页面上提交错误报告。
您退出后正在登录。
public void FacebookLogin()
{
if (FB.IsLoggedIn)
{
FB.LogOut(); //it doesn't work, user is still logged in
return;
}
var permissions = new List<string>() {"email"};
FB.LogInWithReadPermissions(permissions); //t
}
我在我的应用程序上用用户登录了 facebook。
稍后当我在我的 Facebook 应用程序和浏览器上手动注销该用户时,
(FB.IsLoggedIn) 仍然 returns 正确。 出于某种原因,旧的配置文件已保存,我无法使用新用户登录
这是我的代码:
public void FacebookLogin()
{
if (FB.IsLoggedIn)
FB.LogOut(); //it doesn't work, user is still logged in
var permissions = new List<string>() {"email"};
FB.LogInWithReadPermissions(permissions); //trying to login a new user, but the last user is still logged in
将您的 FacebookLogin
函数更改为协程函数。通过这样做,您可以检查用户是否已登录,注销用户然后等待每一帧直到 FB.IsLoggedIn
是 false
,然后您才能登录另一个用户。还要在等待中添加一个计时器,这样当 FB.IsLoggedIn
在 x
时间内永远不会 false
时,函数不会继续到 运行 而是显示一些错误并退出.
public IEnumerator FacebookLogin()
{
//5 seconds loggout time
float waitTimeOut = 5f;
//Log out if loggedin
if (FB.IsLoggedIn)
FB.LogOut(); //it doesn't work, user is still logged in
//Wait until logout is done. Also add a timeout to the wait so that it doesnt wait forever
float timer = 0;
while (FB.IsLoggedIn)
{
if (timer > waitTimeOut)
{
Debug.LogError("Failed to log out within " + waitTimeOut + " seconds");
yield break;
}
timer += Time.deltaTime;
yield return null;
}
Debug.Log("Successfully logged out. Now logging another user in");
var permissions = new List<string>() { "email" };
FB.LogInWithReadPermissions(permissions); //trying
}
如果您仍然对此有疑问,您需要使用此答案中的代码在 facebook-sdk-for-unity Github 页面上提交错误报告。
您退出后正在登录。
public void FacebookLogin()
{
if (FB.IsLoggedIn)
{
FB.LogOut(); //it doesn't work, user is still logged in
return;
}
var permissions = new List<string>() {"email"};
FB.LogInWithReadPermissions(permissions); //t
}