diff --git a/sdk-intergration/Assets/Scripts/SDKTest.cs b/sdk-intergration/Assets/Scripts/SDKTest.cs index 8159019..3be9b80 100644 --- a/sdk-intergration/Assets/Scripts/SDKTest.cs +++ b/sdk-intergration/Assets/Scripts/SDKTest.cs @@ -39,6 +39,7 @@ public class SDKTest : MonoBehaviour private async void OnLogin(EAccoutType accoutType) { _messageTxt.text = string.Empty; + Debug.LogError($"[AggSdk::OnLogin] accoutType : {accoutType}"); var info = await TYSdkFacade.Instance.Login(accoutType); _messageTxt.text = $"Login: {info.isSuccess}"; if(info.isSuccess) diff --git a/sdk-intergration/Packages/tysdk/Plugins/Android/SDKManager.java b/sdk-intergration/Packages/tysdk/Plugins/Android/SDKManager.java index bcf2844..2216a77 100644 --- a/sdk-intergration/Packages/tysdk/Plugins/Android/SDKManager.java +++ b/sdk-intergration/Packages/tysdk/Plugins/Android/SDKManager.java @@ -7,12 +7,12 @@ import android.os.Looper; import android.text.TextUtils; import android.util.Log; -//import com.barton.log.GASDKFactory; -//import com.barton.log.builder.GAConfiguration; -//import com.barton.log.builder.ParamsBuilder; -//import com.barton.log.ebarton.BaseUrl; -//import com.barton.log.ebarton.EventType; -//import com.barton.log.logapi.IGASDK; +import com.barton.log.GASDKFactory; +import com.barton.log.builder.GAConfiguration; +import com.barton.log.builder.ParamsBuilder; +import com.barton.log.ebarton.BaseUrl; +import com.barton.log.ebarton.EventType; +import com.barton.log.logapi.IGASDK; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.tuyoo.gamesdk.api.SDKAPI; @@ -36,7 +36,7 @@ import java.util.Map; public class SDKManager { private final static Handler handler = new Handler(Looper.getMainLooper()); - // private static IGASDK gasdk; + private static IGASDK gasdk; private static final String TAG = com.unity3d.player.SDKManager.class.getSimpleName(); private static String curType = TuYooClientID.tyGuest; public static void InitSDK(Activity activity) @@ -153,6 +153,18 @@ public class SDKManager { }); } + public static void UnityLogin(String type) { + curType = type; + Log.e(TAG,"UnityLogin : " + type); + SDKLog.i("UnityLogin : " + type); + handler.post(new Runnable() { + @Override + public void run() { + SDKAPI.getIns().loginByType(type, mLogin); + } + }); + } + public static void UnityLoginOut() { // Log.e(TAG,"UnityLoginOut!!!"); SDKLog.i("UnityLoginOut : "); @@ -247,55 +259,55 @@ public class SDKManager { }); } -// private static IGASDK GetGameGa(){ -// if(gasdk == null){ -// GAConfiguration.Builder builder = new GAConfiguration.Builder() -// .withBaseUrl(BaseUrl.INTERNAL) -// .withContext(SDKWrapper.getInstance().getContext()) -// .withClientId(ConfigManager.SDK_CLIENTID) -// .withGameId(ConfigManager.SDK_GAMEID) -// .withProjectId(ConfigManager.SDK_PROJECTID); -// gasdk = GASDKFactory.createGASDK(builder.build()); -// } -// return gasdk; -// } + private static IGASDK GetGameGa(){ + if(gasdk == null){ + GAConfiguration.Builder builder = new GAConfiguration.Builder() + .withBaseUrl(BaseUrl.INTERNAL) + .withContext(SDKWrapper.getInstance().getContext()) + .withClientId(ConfigManager.SDK_CLIENTID) + .withGameId(ConfigManager.SDK_GAMEID) + .withProjectId(ConfigManager.SDK_PROJECTID); + gasdk = GASDKFactory.createGASDK(builder.build()); + } + return gasdk; + } public static void SetGaUserInfo(String userId) { -// Log.e(TAG,"SetGaUserInfo : " + userId); -// SDKLog.i("SetGaUserInfo : " + userId); -// GetGameGa().setUserId(userId); + Log.e(TAG,"SetGaUserInfo : " + userId); + SDKLog.i("SetGaUserInfo : " + userId); + GetGameGa().setUserId(userId); } public static void SetGaCommonInfo(String SetGaCommonInfo) { -// Log.e(TAG,"SetGaCommonInfo : " + SetGaCommonInfo); -// SDKLog.i("SetGaCommonInfo : " + SetGaCommonInfo); -// Gson gson = new Gson(); -// Map map = gson.fromJson(SetGaCommonInfo, new TypeToken>(){}.getType()); -// for (String key : map.keySet()) { -// System.out.println("Key = " + key + ", Value = " + map.get(key)); -// if(!TextUtils.isEmpty(key) && map.get(key) != null){ -// GetGameGa().addCommonParameter(key, map.get(key).toString()); -// } -// } + Log.e(TAG,"SetGaCommonInfo : " + SetGaCommonInfo); + SDKLog.i("SetGaCommonInfo : " + SetGaCommonInfo); + Gson gson = new Gson(); + Map map = gson.fromJson(SetGaCommonInfo, new TypeToken>(){}.getType()); + for (String key : map.keySet()) { + System.out.println("Key = " + key + ", Value = " + map.get(key)); + if(!TextUtils.isEmpty(key) && map.get(key) != null){ + GetGameGa().addCommonParameter(key, map.get(key).toString()); + } + } } public static void GAReportParams(int type, String eventstr, String paramstr) { -// Log.e(TAG,"GAReportParams : " + type + " \n" + eventstr + " \n" + paramstr); -// -// SDKLog.i("GAReportParams : " + type + " \n" + eventstr + " \n" + paramstr); -// ParamsBuilder paramsBuilder = ParamsBuilder.newInstance(); -// Gson gson = new Gson(); -// Map map = gson.fromJson(paramstr, new TypeToken>(){}.getType()); -// for (String key : map.keySet()) { -// System.out.println("Key = " + key + ", Value = " + map.get(key)); -// if(!TextUtils.isEmpty(key) && map.get(key) != null){ -// paramsBuilder.append(key, map.get(key).toString()); -// } -// } -// GetGameGa().track(EventType.TRACK, eventstr, paramsBuilder); + Log.e(TAG,"GAReportParams : " + type + " \n" + eventstr + " \n" + paramstr); + + SDKLog.i("GAReportParams : " + type + " \n" + eventstr + " \n" + paramstr); + ParamsBuilder paramsBuilder = ParamsBuilder.newInstance(); + Gson gson = new Gson(); + Map map = gson.fromJson(paramstr, new TypeToken>(){}.getType()); + for (String key : map.keySet()) { + System.out.println("Key = " + key + ", Value = " + map.get(key)); + if(!TextUtils.isEmpty(key) && map.get(key) != null){ + paramsBuilder.append(key, map.get(key).toString()); + } + } + GetGameGa().track(EventType.TRACK, eventstr, paramsBuilder); } } diff --git a/sdk-intergration/Packages/tysdk/Runtime/TYSdkModel.cs b/sdk-intergration/Packages/tysdk/Runtime/TYSdkModel.cs index f1bbf50..c9bc20e 100644 --- a/sdk-intergration/Packages/tysdk/Runtime/TYSdkModel.cs +++ b/sdk-intergration/Packages/tysdk/Runtime/TYSdkModel.cs @@ -8,6 +8,13 @@ namespace tysdk hwGuest, none } + + public class EAccoutTypeName + { + public static string hwGoogle = "hwGoogle"; + public static string hwFacebook = "hwFacebook"; + public static string hwGuest = "hwGuest"; + } public interface ITYSdkCallback { } public class LoginInfo : ITYSdkCallback diff --git a/sdk-intergration/Packages/tysdk/Runtime/UnityBridgeFunc.cs b/sdk-intergration/Packages/tysdk/Runtime/UnityBridgeFunc.cs index a90d27f..9e89683 100644 --- a/sdk-intergration/Packages/tysdk/Runtime/UnityBridgeFunc.cs +++ b/sdk-intergration/Packages/tysdk/Runtime/UnityBridgeFunc.cs @@ -1,3 +1,4 @@ +using System; using System.Runtime.InteropServices; using UnityEngine; @@ -6,6 +7,7 @@ namespace tysdk public static class UnityBridgeFunc { + #if UNITY_EDITOR //初始化sdk public static void InitSDK(){} @@ -51,8 +53,7 @@ namespace tysdk public static void UnityLoadRvADS(){} - public static void UnityShowRVAD(){} - + public static void UnityShowRVAD() { } #elif UNITY_ANDROID @@ -89,10 +90,11 @@ namespace tysdk public static void UnityLogin(EAccoutType accoutType) { - + var typeName = GetLoginTypeName(accoutType); + Debug.LogError("typeName:::" + typeName); using(var sdkManager = new AndroidJavaClass(SDK_CLASS)) { - sdkManager.CallStatic("UnityLogin", accoutType); + sdkManager.CallStatic("UnityLogin", typeName); } } @@ -193,6 +195,7 @@ namespace tysdk public static void UnityLoadRvADS(){} public static void UnityShowRVAD(){} + #elif UNITY_IOS @@ -277,5 +280,24 @@ namespace tysdk [DllImport("__Internal")] public static extern int GetATT(); #endif + + public static string GetLoginTypeName(EAccoutType accoutType) + { + string str = String.Empty; + switch (accoutType) + { + case EAccoutType.hwGoogle: + str = EAccoutTypeName.hwGoogle; + break; + case EAccoutType.hwFacebook: + str = EAccoutTypeName.hwFacebook; + break; + case EAccoutType.hwGuest: + str = EAccoutTypeName.hwGuest; + break; + } + + return str; + } } }