ATSDKAPI.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Reflection;
  4. using System;
  5. using UnityEngine;
  6. using AnyThinkAds.Common;
  7. using AnyThinkAds.ThirdParty.LitJson;
  8. namespace AnyThinkAds.Api
  9. {
  10. public interface ATGetUserLocationListener
  11. {
  12. void didGetUserLocation(int location);
  13. }
  14. public interface ATConsentDismissListener
  15. {
  16. void onConsentDismiss();
  17. }
  18. public interface ATGetAreaListener
  19. {
  20. void onArea(string area);
  21. void onError(string message);
  22. }
  23. public class ATSDKAPI
  24. {
  25. public static readonly int kATUserLocationUnknown = 0;
  26. public static readonly int kATUserLocationInEU = 1;
  27. public static readonly int kATUserLocationOutOfEU = 2;
  28. public static readonly int PERSONALIZED = 0;
  29. public static readonly int NONPERSONALIZED = 1;
  30. public static readonly int UNKNOWN = 2;
  31. public static readonly int AREA_GLOBAL = 0;
  32. public static readonly int AREA_CHINESE_MAINLAND = 1;
  33. //for android and ios
  34. public static readonly string OS_VERSION_NAME = "os_vn";
  35. public static readonly string OS_VERSION_CODE = "os_vc";
  36. public static readonly string APP_PACKAGE_NAME = "package_name";
  37. public static readonly string APP_VERSION_NAME = "app_vn";
  38. public static readonly string APP_VERSION_CODE = "app_vc";
  39. public static readonly string BRAND = "brand";
  40. public static readonly string MODEL = "model";
  41. public static readonly string DEVICE_SCREEN_SIZE = "screen";
  42. public static readonly string MNC = "mnc";
  43. public static readonly string MCC = "mcc";
  44. public static readonly string LANGUAGE = "language";
  45. public static readonly string TIMEZONE = "timezone";
  46. public static readonly string USER_AGENT = "ua";
  47. public static readonly string ORIENTATION = "orient";
  48. public static readonly string NETWORK_TYPE = "network_type";
  49. //for android
  50. public static readonly string INSTALLER = "it_src";
  51. public static readonly string ANDROID_ID = "android_id";
  52. public static readonly string GAID = "gaid";
  53. public static readonly string MAC = "mac";
  54. public static readonly string IMEI = "imei";
  55. public static readonly string OAID = "oaid";
  56. //for ios
  57. public static readonly string IDFA = "idfa";
  58. public static readonly string IDFV = "idfv";
  59. private static readonly IATSDKAPIClient client = GetATSDKAPIClient();
  60. public static void initSDK(string appId, string appKey)
  61. {
  62. client.initSDK(appId, appKey);
  63. }
  64. public static void initSDK(string appId, string appKey, ATSDKInitListener listener)
  65. {
  66. client.initSDK(appId, appKey, listener);
  67. }
  68. public static void showDebuggerUI()
  69. {
  70. client.showDebuggerUI();
  71. }
  72. public static void showDebuggerUI(string debugKey)
  73. {
  74. client.showDebuggerUI(debugKey);
  75. }
  76. public static void setGDPRLevel(int level)
  77. {
  78. client.setGDPRLevel(level);
  79. }
  80. public static void getUserLocation(ATGetUserLocationListener listener)
  81. {
  82. client.getUserLocation(listener);
  83. }
  84. public static int getGDPRLevel() {
  85. return client.getGDPRLevel();
  86. }
  87. public static bool isEUTraffic() {
  88. return client.isEUTraffic();
  89. }
  90. public static void setChannel(string channel)
  91. {
  92. client.setChannel(channel);
  93. }
  94. public static void setSubChannel(string subChannel)
  95. {
  96. client.setSubChannel(subChannel);
  97. }
  98. public static void initCustomMap(Dictionary<string, string> customMap)
  99. {
  100. client.initCustomMap(JsonMapper.ToJson(customMap));
  101. }
  102. public static void setCustomDataForPlacementID(Dictionary<string, string> customData, string placementID)
  103. {
  104. client.setCustomDataForPlacementID(JsonMapper.ToJson(customData), placementID);
  105. }
  106. public static void showGDPRAuth()
  107. {
  108. client.showGDPRAuth();
  109. }
  110. public static void showGDPRConsentDialog(ATConsentDismissListener listener)
  111. {
  112. client.showGDPRConsentDialog(listener);
  113. }
  114. public static void setLogDebug(bool isDebug)
  115. {
  116. client.setLogDebug(isDebug);
  117. ATLogger.IsDebug = isDebug;
  118. }
  119. public static void addNetworkGDPRInfo(int networkType, Dictionary<string,object> dictionary)
  120. {
  121. client.addNetworkGDPRInfo(networkType, JsonMapper.ToJson(dictionary));
  122. }
  123. public static void deniedUploadDeviceInfo(string[] deniedInfo)
  124. {
  125. if (deniedInfo != null && deniedInfo.Length > 0)
  126. {
  127. string deniedString = JsonMapper.ToJson(deniedInfo);
  128. client.deniedUploadDeviceInfo(deniedString);
  129. Debug.Log("deniedUploadDeviceInfo, deniedInfo === " + deniedString);
  130. }
  131. else
  132. {
  133. Debug.Log("deniedUploadDeviceInfo, deniedInfo = null");
  134. }
  135. }
  136. private static IATSDKAPIClient GetATSDKAPIClient(){
  137. Debug.Log("GetATSDKAPIClient");
  138. return AnyThinkAds.ATAdsClientFactory.BuildSDKAPIClient();
  139. }
  140. public static void setExcludeBundleIdArray(string[] bundleIds)
  141. {
  142. if (bundleIds != null && bundleIds.Length > 0)
  143. {
  144. string bundleIdsString = JsonMapper.ToJson(bundleIds);
  145. Debug.Log("setExcludeBundleIdArray, bundleIdsString === " + bundleIdsString);
  146. client.setExcludeBundleIdArray(bundleIdsString);
  147. }
  148. else
  149. {
  150. Debug.Log("setExcludeBundleIdArray, bundleIdsString = null");
  151. }
  152. }
  153. public static void setExcludeAdSourceIdArrayForPlacementID(string placementID, string[] adSourceIds)
  154. {
  155. if (adSourceIds != null && adSourceIds.Length > 0)
  156. {
  157. string adSourceIdsString = JsonMapper.ToJson(adSourceIds);
  158. Debug.Log("setExcludeAdSourceIdArrayForPlacementID, adSourceIdsString === " + adSourceIdsString);
  159. client.setExcludeAdSourceIdArrayForPlacementID(placementID, adSourceIdsString);
  160. }
  161. else
  162. {
  163. Debug.Log("setExcludeAdSourceIdArrayForPlacementID, adSourceIdsString = null");
  164. }
  165. }
  166. public static void setSDKArea(int area)
  167. {
  168. client.setSDKArea(area);
  169. }
  170. public static void getArea(ATGetAreaListener listener)
  171. {
  172. client.getArea(listener);
  173. }
  174. public static void setWXStatus(bool install)
  175. {
  176. client.setWXStatus(install);
  177. }
  178. public static void setLocation(double longitude, double latitude)
  179. {
  180. client.setLocation(longitude, latitude);
  181. }
  182. }
  183. }