예제 #1
0
 void Awake()
 {
     goMenu = false;
     DFB.FBInit();
     showGift       = true;
     showFullBanner = false;
 }
예제 #2
0
    public void LoginButton(bool hideLoading = true)
    {
        //MobilePlugin.getInstance().ShowToast("Click login");
        string error = "";

        //AudioControl.DPlaySound("Click 1");
        try
        {
            if (FB.IsInitialized)
            {
                if (FB.IsLoggedIn)
                {
                    HideLoginDialog();
                    GetFriendsList();
                    loginButton.gameObject.SetActive(false);
                    transform.FindChild("Button").FindChild("ButtonShowMessage").gameObject.SetActive(true);
                    //    transform.FindChild("Button").FindChild("ButtonInviteFriend").gameObject.SetActive(true);
                    //       transform.FindChild("Button").FindChild("ButtonHelpFriend").gameObject.SetActive(true);
                }
                else
                {
                    DFB.FBLogin(result =>
                    {
                        //MobilePlugin.getInstance().ShowToast("FB.IsLoggedIn " + FB.IsLoggedIn);
                        if (FB.IsLoggedIn)
                        {
                            loginButton.gameObject.SetActive(false);
                            transform.FindChild("Button").FindChild("ButtonShowMessage").gameObject.SetActive(true);
                            //     transform.FindChild("Button").FindChild("ButtonInviteFriend").gameObject.SetActive(true);
                            //    transform.FindChild("Button").FindChild("ButtonHelpFriend").gameObject.SetActive(true);
                            //get friends list
                            GetFriendsList();
                            //count message
                            CountMessage();
                            //Get info user
                            if (String.IsNullOrEmpty(PlayerPrefs.GetString(DataCache.FB_ID, "")))
                            {
                                FB.API("v2.2/me", Facebook.HttpMethod.GET, rsl =>
                                {
                                    IDictionary dict1 = Json.Deserialize(rsl.Text) as IDictionary;
                                    if (dict1 != null && dict1["id"] != null)
                                    {
                                        DFB.UserId   = "" + dict1["id"];
                                        DFB.UserName = "" + dict1["name"];
                                        PlayerPrefs.SetString(DataCache.FB_ID, DFB.UserId);
                                        PlayerPrefs.SetString(DataCache.FB_USER, DFB.UserName);
                                        try
                                        {
                                            AudioControl.getMonoBehaviour().StartCoroutine(DHS.PostMeInfo(DFB.UserId, DFB.UserName, "" + dict1["locale"], "" + dict1["last_name"]));
                                        }
                                        catch (Exception e)
                                        {
                                            ShowConfirm();
                                            Debug.Log("--------------------catch error StartCoroutine-------------------" + e.Message);
                                            error = "" + e.Message;
                                        }
                                    }
                                });
                            }
                            else
                            {
                                DFB.UserId   = PlayerPrefs.GetString(DataCache.FB_ID);
                                DFB.UserName = PlayerPrefs.GetString(DataCache.FB_USER);
                            }
                        }
                        else
                        {
                            ShowConfirm();
                        }
                    });
                }
            }
            else
            {
                DFB.FBInit();
                ShowConfirm();
            }
        }
        catch (Exception e)
        {
            ShowConfirm();
            Debug.Log("--------------------Error Login FB-------------------" + e.Message);
            error = "" + e.Message;
        }
        //MobilePlugin.getInstance().ShowToast("error " + error);
    }