Пример #1
0
    IEnumerator Initialize_()
    {
        App = FirebaseApp.DefaultInstance;
        FirebaseApp.LogLevel = LogLevel.Info;
        proj_id = App.Options.MessageSenderId;

        default_header = new Dictionary <string, string>()
        {
            { "Content-Type", "application/json" },
            { "Authorization", "key=" + server_key },
            { "project_id", proj_id }
        };

        while (!User.Initialized)
        {
            yield return(null);
        }

        /*Firebase_Handler.Singleton.GoogleAnalytics.LogScreen("Login_S");
         * Firebase_Handler.Singleton.GoogleAnalytics.LogEvent("Category_Example", "Event_Action", "Event_Label", 1);
         * Firebase_Handler.Singleton.GoogleAnalytics.LogEvent(new EventHitBuilder().SetEventCategory("login").SetEventAction("login"));
         * Firebase_Handler.Singleton.GoogleAnalytics.DispatchHits();*/

        Set_User_Property("user_id", User.User_Info.Id.ToString());

        #if !UNITY_EDITOR
        Firebase_Handler.Modify_Registration_Token(Firebase_Handler.Operation.add);
        #endif

        Debug.Log("Firebase initialized successfully. Data:" +
                  "\nProjectId: " + App.Options.ProjectId +
                  "\nMessageSenderId: " + App.Options.MessageSenderId +
                  "\nAppId: " + App.Options.AppId +
                  "\nApiKey: " + App.Options.ApiKey);

        yield return(null);
    }
Пример #2
0
    public void Logout()
    {
        Database_Handler.Initialize_Dictionaries();
        string lock_pwd = PlayerPrefs.GetString("lock_pwd");
        string db_key   = PlayerPrefs.GetString("db_key");

        PlayerPrefs.DeleteAll();
        PlayerPrefs.SetString("lock_pwd", lock_pwd);
        PlayerPrefs.SetString("db_key", db_key);

        Firebase_Handler.Modify_Registration_Token(Firebase_Handler.Operation.remove, new Firebase_Handler.FCM_Params()
        {
            Concluding_Method = (object[] data) =>
            {
                User.Initialized = false;
                Firebase_Handler.Singleton.enabled    = true;
                Firebase_Handler.Own_Notification_Key = "";
                Scroll_Updater.Initialize();

                for (int x = 0; x < SceneManager.sceneCount; x++)
                {
                    Scene scene = SceneManager.GetSceneAt(x);

                    if (scene.name != "Login")
                    {
                        SceneManager.UnloadSceneAsync(scene);
                    }
                }

                User.User_Info = new User.User_Information {
                    Username = ""
                };
            }
        });

        Login.Singleton.Reset_Input_Fields();
    }