Exemple #1
0
        public void Pay(EB.IAP.Item item, EB.IAP.Transaction transaction, Action <string, object> callback)
        {
            EB.Debug.Log("HuaweiSDKManager.Pay");
            if (!mInitialized)
            {
                EB.Debug.LogError("HuaweiSDKManager.Pay: not initialized");
                callback("have not init sdk", null);
                return;
            }

            var extraInfo = JSON.Parse(transaction.payload);

            EB.Debug.Log("HuaweiSDKManager extraInfo = {0}", transaction.payload);

            string payPrivateKey = EB.Dot.String("privateKey", extraInfo, string.Empty);

            EB.Debug.Log("HuaweiSDKManager payPrivateKey = {0}", payPrivateKey);

            mPayCallback += callback;
            var    user = Hub.Instance.LoginManager.LocalUser;
            string cost = item.cost.ToString("#0.00");

            EB.Debug.Log("HuaweiSDKManager cost = {0}", cost);
            HuaweiSDK.Pay(appId, payId, user.Name, cost, item.longName, transaction.transactionId, item.localizedDesc, payPrivateKey);
        }
Exemple #2
0
        public void Login(Action <string, object> callback)
        {
            EB.Debug.Log("HuaweiSDKManager.Login");
            if (!mInitialized)
            {
                callback("TencentSDK has not been inited", null);
                return;
            }

            //EB.Debug.Log("HuaweiSDKManager.Login 0");
            //EB.Debug.Log("HuaweiSDKManager.Login 1");

            mLoginCallback     += callback;
            Hub.RunInBackground = true;

            if (!mSDKLogout)
            {
                HuaweiSDK.Login();
                HuaweiSDK.CheckUpdate();
            }
            else
            {
                mSDKLogout = false;
                mLogined   = true;
                if (mLoginCallback != null)
                {
                    mLoginCallback(null, mLoginData);
                    mLoginCallback = null;
                }
            }
        }
Exemple #3
0
 public void InitSDK(object initData, Action <string, bool> callback)
 {
     if (mInitialized)
     {
         EB.Debug.Log("HuaweiSDKManager.InitSDK: Initialized");
         callback(null, true);
         return;
     }
     if (Application.platform != RuntimePlatform.Android)
     {
         callback(null, false);
         return;
     }
     EB.Debug.Log("HuaweiSDKManager.InitSDK: initData = {0}", JSON.Stringify(initData));
     appId          = EB.Dot.String("appId", initData, string.Empty);
     payId          = EB.Dot.String("payId", initData, string.Empty);
     buoyPrivateKey = EB.Dot.String("buoyPrivateKey", initData, string.Empty);
     EB.Debug.Log("HuaweiSDKManager.InitSDK: appId = {0}", appId);
     EB.Debug.Log("HuaweiSDKManager.InitSDK: payId = {0}", payId);
     EB.Debug.Log("HuaweiSDKManager.InitSDK: buoyPrivateKey = {0}", buoyPrivateKey);
     mInitCallback      += callback;
     Hub.RunInBackground = true;
     new GameObject("huawei_plugin_listener", typeof(SparxHuaweiSDKManager));
     HuaweiSDK.InitSDK(appId, payId, buoyPrivateKey);
 }
Exemple #4
0
        public void SetPlayerInfo()
        {
            var    user      = Hub.Instance.LoginManager.LocalUser;
            var    worlds    = Hub.LoginManager.GameWorlds;
            var    world     = System.Array.Find(worlds, w => w.Id == user.WorldId);
            string worldName = world != null ? world.Name : (worlds.Length > 0 ? worlds[0].Name : "Default");

            //string sociatyName = EB.Localizer.GetString("ID_LABEL_NAME_NONE") + EB.Localizer.GetString("ID_ALLIANCE");
            HuaweiSDK.SetPlayerInfo(user.Level.ToString(), user.Name, worldName, "");
        }
Exemple #5
0
 void OnApplicationPause(bool pauseStatus)
 {
     if (pauseStatus)
     {
         EB.Debug.Log("HuaweiSDKManager.OnEnteredBackground");
         HuaweiSDK.HideFloatWindow();
     }
     else
     {
         EB.Debug.Log("HuaweiSDKManager.OnEnteredForeground");
         HuaweiSDK.ShowFloatWindow();
         SparxHub.Instance.HuaweiSDKManager.OnLoginEnteredForeground();
     }
 }
Exemple #6
0
 public void OnLoginEnteredForeground()
 {
     if (mLoginCallback != null)
     {
         EB.Coroutines.SetTimeout(delegate()
         {
             if (mLoginCallback != null)
             {
                 HuaweiSDK.DestorySDK();
                 mInitialized  = false;
                 mInitCallback = null;
                 mLogined      = false;
                 HuaweiSDK.InitSDK(appId, payId, buoyPrivateKey);
                 System.Action <string, object> callback = mLoginCallback;
                 EB.Debug.Log("HuaweiSDKManager.OnLogin OnLoginEnteredForeground");
                 mLoginCallback = null;
                 callback(null, null);
             }
         }, 1 * 1000);
     }
 }
Exemple #7
0
 void OnApplicationQuit()
 {
     HuaweiSDK.DestorySDK();
     Hub.Instance.HuaweiSDKManager.OnSDKDestory();
 }