コード例 #1
0
    //Make sure that this method will be called only once per app session
    private void Start()
    {
        //This can be done via editor menu
        SA_FB_Settings.Instance.SetAppId("1605471223039154");


        //This can also be done via the settings
        //We need email scope to be able to get user email
        if (!SA_FB_Settings.Instance.Scopes.Contains("email"))
        {
            SA_FB_Settings.Instance.Scopes.Add("email");
        }

        if (!SA_FB_Settings.Instance.Scopes.Contains("user_gender"))
        {
            SA_FB_Settings.Instance.Scopes.Add("user_gender");
        }

        if (!SA_FB_Settings.Instance.Scopes.Contains("user_location"))
        {
            SA_FB_Settings.Instance.Scopes.Add("user_location");
        }

        if (!SA_FB_Settings.Instance.Scopes.Contains("user_age_range"))
        {
            SA_FB_Settings.Instance.Scopes.Add("user_age_range");
        }


        m_connect.interactable = false;
        SA_FB.Init(() => {
            Debug.Log("Init Completed");
            m_connect.interactable = true;
            UpdateAccountUI();
        });



        //let's define button action based on user state
        m_connect.onClick.AddListener(() => {
            if (!SA_FB.IsLoggedIn)
            {
                SignInFlow();
            }
            else
            {
                SignOutFlow();
            }
        });
    }
コード例 #2
0
    void Start()
    {
        //Unity settings via code example
        UM_Settings.Instance.Analytics.UnityClient.LimitUserTracking  = true;
        UM_Settings.Instance.Analytics.UnityClient.DeviceStatsEnabled = true;

        //Firebase settings via code
        UM_Settings.Instance.Analytics.FirebaseClient.SessionTimeoutDuration = 30;

        if (SA_FB.IsSDKInstalled)
        {
            SA_FB.Init();
        }

        m_InitButton.onClick.AddListener(() =>
        {
            UM_AnalyticsService.Client.Init();

            //Demographics
            UM_AnalyticsService.Client.SetUserId(SystemInfo.deviceUniqueIdentifier);
            UM_AnalyticsService.Client.SetUserGender(UM_Gender.Male);
            UM_AnalyticsService.Client.SetUserBirthYear(1989);
        });

        m_LogSimpleEventButton.onClick.AddListener(() =>
        {
            UM_AnalyticsService.Client.Event("my_simple_event");
        });

        m_LogDataEventButton.onClick.AddListener(() =>
        {
            var data = new Dictionary <string, object>();
            data.Add("key_1", 100);
            data.Add("key_2", "Hello World");
            UM_AnalyticsService.Client.Event("my_data_event", data);
        });

        m_LogTransactionButton.onClick.AddListener(() =>
        {
            var productId = "my_item";
            float amount  = 1;
            var currency  = "USD";

            UM_AnalyticsService.Client.Transaction(productId, amount, currency);
        });
    }