Facebook UNITY SDK 登录问题 [英] Facebook UNITY SDK login issue

查看:104
本文介绍了Facebook UNITY SDK 登录问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了新版本的 Unity 4.3 和新的 facebook sdk,但无法正常工作.

I just installed the new version of Unity 4.3 and the new facebook sdk and I can't get it working.

我在 facebook 上创建了应用程序,根据需要将应用程序 ID 复制到统一的 facebook 设置,并将包名称和类名称复制回 facebook.

I created the app on facebook, copied over the app id to the unity facebook settings as required and copied the Package Name and Class name back to facebook.

因为 Android Key Hash 是空的(即使它不应该是),我使用其他人发布的方法用 openssl 创建了一个.我创建了它并根据需要复制到 Facebook.

Because the Android Key Hash is empty ( even it shouldn't be ) I used the methods posted by others to create one with openssl. I created it and copied over to facebook as required.

在此之后,我创建了一个能够登录的小脚本.

After this I created a small script to be able to login.

// Use this for initialization
void Start () {
    enabled = false;                  
    FB.Init(SetInit, OnHideUnity);  
}

// Update is called once per frame
void Update () {

}

private void SetInit()                                                                       
{                                                                                            
    FbDebug.Log("SetInit");                                                                  
    enabled = true; // "enabled" is a property inherited from MonoBehaviour                  
    if (FB.IsLoggedIn)                                                                       
    {                                                                                        
        FbDebug.Log("Already logged in");                                                    
        OnLoggedIn();                                                                        
    }                                                                                        
}                                                                                            

private void OnHideUnity(bool isGameShown)                                                   
{                                                                                            
    FbDebug.Log("OnHideUnity");                                                              
    if (!isGameShown)                                                                        
    {                                                                                        
        // pause the game - we will need to hide                                             
        Time.timeScale = 0;                                                                  
    }                                                                                        
    else                                                                                     
    {                                                                                        
        // start the game back up - we're getting focus again                                
        Time.timeScale = 1;                                                                  
    }                                                                                        
}    

void OnGUI(){
    if (!FB.IsLoggedIn)                                                                                              
    {                                                                                                                         
        if (GUI.Button(new Rect(179 , 11, 287, 160), "Login to Facebook"))                                      
        {                                                                                                            
            FB.Login("email", LoginCallback);                                                        
        }                                                                                                            
    }    
}

void LoginCallback(FBResult result)                                                        
{                                                                                          
    FbDebug.Log("LoginCallback");                                                          
    Debug.Log("LoginCallback");
    if (FB.IsLoggedIn)                                                                     
    {                                                                                      
        OnLoggedIn();                                                                      
    }                                                                                      
}                                                                                          

void OnLoggedIn()                                                                          
{                                                                                          
    FbDebug.Log("Logged in. ID: " + FB.UserId);                                            
} 

现在,当我单击登录按钮时,会出现一个请求许可的 Facebook 窗口,在我按确定后,它返回,但我仍未登录...有人可以帮忙这是为什么吗?我观察到的另一件奇怪的事情是,只要我点击登录按钮,LoginCallback 就会被调用,尽管我认为只有在我给予许可时才会调用它.无论如何,当我给予许可时,它会返回到我的应用程序,并且没有任何反应.我可以再次点击登录按钮,同样的事情发生,登录回调调用,它要求权限,我给权限并返回,什么也没发生.有人可以帮忙吗?

Now when I click on the login button a Facebook window appears requesting permission, after I press ok, it returns, but I'm still not logged in... Can anybody help why is this? Another strange thing I observed that the LoginCallback gets called as soon as I click on the login button, even though I would think it should only when I gave permission. Anyway when I give permission it returns to my app and nothing happens. I can click on the login button again and same thing happens, login callback called, it asks for permisions, I give the permision and returns back, nothing happened. Can anybody help?

推荐答案

sdk 的 4.3.6 版应该可以解决这个问题.它可在此处获得:https://developers.facebook.com/ 我们仍在等待它的批准资产商店,所以现在唯一能得到它的地方是 Facebook 的网站.

Version 4.3.6 of the sdk should fix this problem. It's available here: https://developers.facebook.com/ We are still waiting for it to be approved on the asset store, so the only place to get it right now is from Facebook's site.

注意 - 如果您使用 Mac,它仍然会损坏 (5/2014).只需按照Rafael 解决方案",从 public void OnLoginComplete(string message) 中正确发现您的哈希.干杯

Note - it's still broken (5/2014) IF you use a Mac. Just follow the "Rafael solution", discover your hash properly from public void OnLoginComplete(string message). Cheers

这篇关于Facebook UNITY SDK 登录问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆