123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using AnyThinkAds.Common;
- using AnyThinkAds.Api;
- namespace AnyThinkAds.Android
- {
- public class ATSDKAPIClient : AndroidJavaProxy, IATSDKAPIClient
- {
- private AndroidJavaObject sdkInitHelper;
- private ATSDKInitListener sdkInitListener;
- public ATSDKAPIClient () : base("com.anythink.unitybridge.sdkinit.SDKInitListener")
- {
- this.sdkInitHelper = new AndroidJavaObject(
- "com.anythink.unitybridge.sdkinit.SDKInitHelper", this);
- }
- public void initSDK(string appId, string appKey)
- {
- this.initSDK(appId, appKey, null);
- }
- public void initSDK(string appId, string appKey, ATSDKInitListener listener)
- {
- Debug.Log("initSDK....");
- sdkInitListener = listener;
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("initAppliction", appId, appKey);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log ("ATSDKAPIClient : error."+e.Message);
- }
- }
- public void getUserLocation(ATGetUserLocationListener listener)
- {
- ATNetTrafficListener netTrafficListener = new ATNetTrafficListener(listener);
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("checkIsEuTraffic", netTrafficListener);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- //implement getting location here
- }
- public void setGDPRLevel(int level)
- {
- Debug.Log ("setGDPRLevel....");
- try{
- if (this.sdkInitHelper != null) {
- this.sdkInitHelper.Call ("setGDPRLevel",level);
- }
- }catch(System.Exception e){
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log ("ATSDKAPIClient : error."+e.Message);
- }
-
- }
- public void showGDPRAuth()
- {
- Debug.Log ("showGDPRAuth....");
- try{
- if (this.sdkInitHelper != null) {
- this.sdkInitHelper.Call ("showGDPRAuth");
- }
- }catch(System.Exception e){
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log ("ATSDKAPIClient : error."+e.Message);
- }
- }
- public void showGDPRConsentDialog(ATConsentDismissListener listener)
- {
- Debug.Log ("showGDPRConsentDialog....");
- ATGDPRConsentDismissListener gdprConsentDismissListener = new ATGDPRConsentDismissListener(listener);
- try{
- if (this.sdkInitHelper != null) {
- this.sdkInitHelper.Call ("showGDPRConsentDialog", gdprConsentDismissListener);
- }
- }catch(System.Exception e){
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log ("ATSDKAPIClient : error."+e.Message);
- }
- }
- public void setChannel(string channel)
- {
- Debug.Log("setChannel....");
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("setChannel", channel);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- }
- public void setSubChannel(string subchannel)
- {
- Debug.Log("setSubChannel....");
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("setSubChannel", subchannel);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- }
- public void initCustomMap(string jsonMap)
- {
- Debug.Log("initCustomMap....");
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("initCustomMap", jsonMap);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- }
- public void setCustomDataForPlacementID(string customData, string placementID)
- {
- Debug.Log("setCustomDataForPlacementID....");
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("initPlacementCustomMap", placementID, customData);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- }
- public void setLogDebug(bool isDebug)
- {
- Debug.Log("setLogDebug....");
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("setDebugLogOpen", isDebug);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- }
- public void addNetworkGDPRInfo(int networkType, string mapJson)
- {
- // Debug.Log ("addNetworkGDPRInfo...." + networkType + "mapjson:"+mapJson);
- // try{
- // if (this.sdkInitHelper != null) {
- // this.sdkInitHelper.Call ("addNetworkGDPRInfo",networkType,mapJson);
- // }
- // }catch(System.Exception e){
- // System.Console.WriteLine("Exception caught: {0}", e);
- // Debug.Log ("ATSDKAPIClient : error."+e.Message);
- // }
- }
- public void initSDKSuccess(string appid)
- {
- Debug.Log("initSDKSuccess...unity3d.");
- if(sdkInitListener != null){
- sdkInitListener.initSuccess();
- }
- }
- public void initSDKError(string appid, string message)
- {
- Debug.Log("initSDKError..unity3d..");
- if (sdkInitListener != null)
- {
- sdkInitListener.initFail(message);
- }
- }
- public int getGDPRLevel()
- {
- Debug.Log("getGDPRLevel....");
- try
- {
- if (this.sdkInitHelper != null)
- {
- return this.sdkInitHelper.Call<int>("getGDPRLevel");
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- return 2; //UNKNOW
- }
- public bool isEUTraffic()
- {
- Debug.Log("isEUTraffic....");
- try
- {
- if (this.sdkInitHelper != null)
- {
- return this.sdkInitHelper.Call<bool>("isEUTraffic");
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- return false;
- }
- public void deniedUploadDeviceInfo(string deniedInfoString)
- {
- Debug.Log("deniedUploadDeviceInfo....");
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("deniedUploadDeviceInfo", deniedInfoString);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- }
- public void setExcludeBundleIdArray(string bundleIds)
- {
- Debug.Log("setExcludeBundleIdArray....");
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("setExcludeBundleIdArray", bundleIds);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- }
- public void setExcludeAdSourceIdArrayForPlacementID(string placementID, string adsourceIds)
- {
- Debug.Log("setExcludeAdSourceIdArrayForPlacementID....");
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("setExcludeAdSourceIdArrayForPlacementID", placementID, adsourceIds);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- }
- public void setSDKArea(int area)
- {
- Debug.Log("setSDKArea....");
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("setSDKArea", area);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- }
- public void getArea(ATGetAreaListener listener)
- {
- Debug.Log("getArea....");
- ATAreaListener areaListener = new ATAreaListener(listener);
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("getArea", areaListener);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- }
- public void setWXStatus(bool install)
- {
- Debug.Log("setWXStatus....");
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("setWXStatus", install);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- }
- public void setLocation(double longitude, double latitude)
- {
- Debug.Log("setLocation....");
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("setLocation", longitude, latitude);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- }
- public void showDebuggerUI() {
- showDebuggerUI("");
- }
- public void showDebuggerUI(string debugKey) {
- try
- {
- if (this.sdkInitHelper != null)
- {
- this.sdkInitHelper.Call("showDebuggerUI", debugKey);
- }
- }
- catch (System.Exception e)
- {
- System.Console.WriteLine("Exception caught: {0}", e);
- Debug.Log("ATSDKAPIClient : error." + e.Message);
- }
- }
- }
- }
|