Пример #1
0
 public override void LogoutDirectly()
 {
     if (_IsLogined)
     {
         KakaoUtil.LogoutWithCustomUI((resultCode) =>
         {
             if (resultCode == KGResultCode.Success)
             {
                 LogResult(_KakaoPrefix, "LogoutDirectly Succeeded", resultCode.ToString());
                 SingularSDK.UnsetCustomUserId();
                 Reset();
                 if (_LogoutCallback != null)
                 {
                     _LogoutCallback(LOGOUT_STATE.LT_LOGOUT_SUCCEED);
                 }
             }
             else
             {
                 LogResult(_KakaoPrefix, "LogoutDirectly Failed", resultCode.ToString());
                 if (_LogoutCallback != null)
                 {
                     _LogoutCallback(LOGOUT_STATE.LT_LOGOUT_FAIL);
                 }
             }
         });
     }
 }
Пример #2
0
    // The Singular SDK is initialized here
    void Awake()
    {
        Debug.Log(string.Format("SingularSDK Awake, InitializeOnAwake={0}", InitializeOnAwake));

        if (Application.isEditor)
        {
            return;
        }

        if (instance)
        {
            return;
        }

        // Initialize singleton
        instance = this;

        // Keep this script running when another scene loads
        DontDestroyOnLoad(gameObject);

        if (InitializeOnAwake)
        {
            Debug.Log("Awake : calling Singular Init");
            InitializeSingularSDK();
        }
    }
Пример #3
0
    private void OnLoginSucceed()
    {
        // Current user id issued by Kakao platform
        string playerId = KGLocalPlayer.currentPlayer.playerId;
        // Access token issued by Kakao platform
        string accessToken = KGSession.accessToken;
        // IDP information
        var idpProfile = KGLocalPlayer.currentPlayer.idpProfile;

        SingularSDK.SetCustomUserId(playerId);

        string nickname = string.Empty;

        if (idpProfile.idpCode.Equals(KGIdpCodeString.Kakao))
        {
            KGKakaoProfile kakaoProfile = idpProfile as KGKakaoProfile;
            nickname = kakaoProfile.nickname;
        }

        USER_INFO userInfo = new USER_INFO();

        userInfo.strUserName    = string.Empty;
        userInfo.strNickName    = nickname;
        userInfo.strUserID      = playerId;
        userInfo.strAccessToken = accessToken;
        userInfo.bGuest         = idpProfile.idpCode.Equals(KGIdpCodeString.Guest);

        _IsLogined = true;
        if (_LoginCallback != null)
        {
            _LoginCallback(LOGIN_STATE.LT_LOGIN_SUCCEED, userInfo);
        }
    }
Пример #4
0
    public override void Unregister(LT_RESULT_NOTIFICATION_DELEGATE callback)
    {
        if (_IsLogined)
        {
            KakaoUtil.Unregister((resultCode) =>
            {
                bool isSuccessful = resultCode == KGResultCode.Success;
                if (isSuccessful)
                {
                    LogResult(_KakaoPrefix, "Unregister Succeeded", resultCode.ToString());
                    _IsLogined = KakaoUtil.IsLogined; // ͬ²½µÇ¼״̬£¨×¢Ïú³É¹¦£¬µÇ¼״̬Ϊfalse£©
                    if (!_IsLogined)
                    {
                        SingularSDK.UnsetCustomUserId();
                    }
                }
                else
                {
                    LogResult(_KakaoPrefix, "Unregister Failed", resultCode.ToString());
                }

                if (callback != null)
                {
                    callback(isSuccessful);
                }
            });
        }
    }
Пример #5
0
    public void SendRevenue_OnClick()
    {
        // Reporting a simple revenue event to Singular of $4.99
        SingularSDK.CustomRevenue("Test Revenue", "USD", 4.99);

        ShowToast("Revenue event sent");
    }
Пример #6
0
    public void SendEvent_OnClick()
    {
        // Reporting a simple event to Singular
        SingularSDK.Event("Test Event");

        ShowToast("Event sent");
    }
Пример #7
0
    public void SetCustomUserId_OnClick()
    {
        string customUserId = "*****@*****.**";

        // Once set, the Custom User Id will persist between runs until `SingularSDK.UnsetCustomUserId()` is called.
        // This can also be called before SDK init if you want the first session to include the Custom User Id.
        SingularSDK.SetCustomUserId(customUserId);

        ShowToast($"Custom User Id was set to '{customUserId}'");
    }
Пример #8
0
    public void InitSDK_OnClick()
    {
        // Here we initialize the SDK manually, instead of using the InitializeOnAwake flag on the SDK Object.
        // By default InitializeOnAwake is true, which will automatically initialize the SDK when the scene loads.
        SingularSDK.InitializeSingularSDK();

        // Registering the class as the Singular Link handler.
        SingularSDK.SetSingularLinkHandler(this);

        ShowToast("SDK initialized");
    }
Пример #9
0
    // ´òµã²¿·ÖÔÝʱдËÀ
    public override void UploadRoleInfo(ROLE_INFO roleInfo)
    {
        if (roleInfo == null)
        {
            return;
        }

        if (roleInfo.roleLevel == 1 || roleInfo.roleLevel == 5 || roleInfo.roleLevel == 10)
        {
            HobaDebuger.LogWarningFormat("{0}UploadRoleInfo level:{1}", _KakaoPrefix, roleInfo.roleLevel.ToString());
            SingularSDK.Event("Level", "level", roleInfo.roleLevel.ToString());
        }
    }
Пример #10
0
    public void SendEventWithArgs_OnClick()
    {
        var attributes = new Dictionary <string, object>()
        {
            ["key1"] = "value1",
            ["key2"] = "value2"
        };

        // Reporting a simple event with your custom attributes to pass with the event
        SingularSDK.Event(attributes, "Test Event With Args");

        ShowToast("Event with args sent");
    }
Пример #11
0
    public void SendInAppPurchase_OnClick()
    {
        var attributes = new Dictionary <string, object>()
        {
            ["key1"] = "value1",
            ["key2"] = "value2"
        };

        // Instead of sending a real product we create a fake one for testing.
        // In your production environment, the Product object should be received from the Unity Purchasing API.
        Product product = BuildProduct();

        SingularSDK.InAppPurchase("Test IAP", product, attributes);

        ShowToast("IAP sent");
    }
Пример #12
0
    public override void CheckLoginStatus()
    {
        bool oldStatus = _IsLogined;
        bool newStatus = KakaoUtil.IsLogined;

        if (!oldStatus && newStatus)
        {
            //¾É״̬ΪδµÇ¼£¬ÐÂ״̬ΪÒѵǼ£¬ÊôÓÚÒì³£
            Common.HobaDebuger.LogErrorFormat("{0}CheckLoginStatus invalid", _KakaoPrefix);
            return;
        }

        _IsLogined = newStatus;
        if (oldStatus && !newStatus)
        {
            SingularSDK.UnsetCustomUserId();
        }
    }
Пример #13
0
    // The Singular SDK is initialized here
    void Awake()
    {
        //Debug.Log(string.Format("SingularSDK Awake, InitializeOnAwake={0}", InitializeOnAwake));

        if (instance)
        {
            return;
        }

        // Initialize singleton
        instance = this;

        // Keep this script running when another scene loads
        DontDestroyOnLoad(gameObject);

        if (InitializeOnAwake)
        {
            //Debug.Log ("Awake : calling Singular Init");
            InitializeSingularSDK();
            SetDeferredDeepLinkHandler(this);
        }
    }
Пример #14
0
    public void OnDebugCmd(string cmd)
    {
        string[] result = cmd.Split(' ');
        if (result.Length == 0 || result.GetLength(0) < 2)
        {
            return;
        }

        if (result[0].Equals("dn"))
        {
            int cmdid = int.Parse(result[1]);
            if (cmdid == 9)
            {
                ChangeWeather(WeatherType.Rain);
            }
            else if (cmdid == 10)
            {
                ChangeWeather(WeatherType.Snow);
            }
            else if (cmdid == 11)
            {
                ChangeWeather(WeatherType.None);
            }
            else if (cmdid == 1)
            {
                DynamicEffectManager.Instance.OnDebugCmd(DynamicEffectType.Morning);
            }
            else if (cmdid == 2)
            {
                DynamicEffectManager.Instance.OnDebugCmd(DynamicEffectType.Day);
            }
            else if (cmdid == 3)
            {
                DynamicEffectManager.Instance.OnDebugCmd(DynamicEffectType.Dusk);
            }
            else if (cmdid == 4)
            {
                DynamicEffectManager.Instance.OnDebugCmd(DynamicEffectType.Night);
            }
            else if (cmdid == 801)
            {
                HobaDebuger.LogError("InitializeSingularSDK");
                SingularSDK.InitializeSingularSDK();
            }
            else if (cmdid == 802)
            {
                // An example login event with no arguments
                HobaDebuger.LogError("SingularSDK.Event");
                SingularSDK.Event("Login");
            }
            else if (cmdid == 803)
            {
                // An example login event passing two key value pairs
                SingularSDK.Event("Login", "Key1", "Value1", "Key2", 1234);
            }
            else if (cmdid == 804)
            {
                // An example JSONEvent passing a dictionary
                SingularSDK.Event(new Dictionary <string, object>()
                {
                    { "Key1", "Value1" },
                    { "Key2", new Dictionary <string, object>()
                      {
                          { "SubKey1", "SubValue1" },
                          { "SubKey2", "SubValue2" }
                      } }
                }, "JSONEvent");
            }
            else if (cmdid == 805)
            {
                // Revenue with no product details
                SingularSDK.Revenue("USD", 9.99);
            }
            else if (cmdid == 806)
            {
                // Revenue with product details
                SingularSDK.Revenue("USD", 50.50, "abc123", "myProductName", "myProductCategory", 2, 25.50);
            }
            else if (cmdid == 807)
            {
                // Set a Custom User ID
                SingularSDK.SetCustomUserId("custom_user_id");

                // Unset a Custom User ID
                SingularSDK.UnsetCustomUserId();
            }
            else if (cmdid == 700)
            {
                //SendDebugData();
            }
            else if (cmdid == 808)
            {
                _BlocksManager.OnDebugCmd(true);
                _ColliderManager.OnDebugCmd(false);
            }
            else if (cmdid == 809)
            {
                _BlocksManager.OnDebugCmd(false);
                _ColliderManager.OnDebugCmd(true);
            }
        }
    }