123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- using System.Collections;
- using System.Collections.Generic;
- using System.Reflection;
- using System;
- using UnityEngine;
- using AnyThinkAds.Common;
- using AnyThinkAds.ThirdParty.LitJson;
- namespace AnyThinkAds.Api
- {
- public interface ATGetUserLocationListener
- {
- void didGetUserLocation(int location);
- }
- public interface ATConsentDismissListener
- {
- void onConsentDismiss();
- }
- public interface ATGetAreaListener
- {
- void onArea(string area);
- void onError(string message);
- }
- public class ATSDKAPI
- {
- public static readonly int kATUserLocationUnknown = 0;
- public static readonly int kATUserLocationInEU = 1;
- public static readonly int kATUserLocationOutOfEU = 2;
- public static readonly int PERSONALIZED = 0;
- public static readonly int NONPERSONALIZED = 1;
- public static readonly int UNKNOWN = 2;
- public static readonly int AREA_GLOBAL = 0;
- public static readonly int AREA_CHINESE_MAINLAND = 1;
- //for android and ios
- public static readonly string OS_VERSION_NAME = "os_vn";
- public static readonly string OS_VERSION_CODE = "os_vc";
- public static readonly string APP_PACKAGE_NAME = "package_name";
- public static readonly string APP_VERSION_NAME = "app_vn";
- public static readonly string APP_VERSION_CODE = "app_vc";
- public static readonly string BRAND = "brand";
- public static readonly string MODEL = "model";
- public static readonly string DEVICE_SCREEN_SIZE = "screen";
- public static readonly string MNC = "mnc";
- public static readonly string MCC = "mcc";
- public static readonly string LANGUAGE = "language";
- public static readonly string TIMEZONE = "timezone";
- public static readonly string USER_AGENT = "ua";
- public static readonly string ORIENTATION = "orient";
- public static readonly string NETWORK_TYPE = "network_type";
- //for android
- public static readonly string INSTALLER = "it_src";
- public static readonly string ANDROID_ID = "android_id";
- public static readonly string GAID = "gaid";
- public static readonly string MAC = "mac";
- public static readonly string IMEI = "imei";
- public static readonly string OAID = "oaid";
- //for ios
- public static readonly string IDFA = "idfa";
- public static readonly string IDFV = "idfv";
- private static readonly IATSDKAPIClient client = GetATSDKAPIClient();
- public static void initSDK(string appId, string appKey)
- {
- client.initSDK(appId, appKey);
- }
- public static void initSDK(string appId, string appKey, ATSDKInitListener listener)
- {
- client.initSDK(appId, appKey, listener);
- }
- public static void showDebuggerUI()
- {
- client.showDebuggerUI();
- }
- public static void showDebuggerUI(string debugKey)
- {
- client.showDebuggerUI(debugKey);
- }
- public static void setGDPRLevel(int level)
- {
- client.setGDPRLevel(level);
- }
- public static void getUserLocation(ATGetUserLocationListener listener)
- {
- client.getUserLocation(listener);
- }
- public static int getGDPRLevel() {
- return client.getGDPRLevel();
- }
- public static bool isEUTraffic() {
- return client.isEUTraffic();
- }
- public static void setChannel(string channel)
- {
- client.setChannel(channel);
- }
- public static void setSubChannel(string subChannel)
- {
- client.setSubChannel(subChannel);
- }
- public static void initCustomMap(Dictionary<string, string> customMap)
- {
- client.initCustomMap(JsonMapper.ToJson(customMap));
- }
- public static void setCustomDataForPlacementID(Dictionary<string, string> customData, string placementID)
- {
- client.setCustomDataForPlacementID(JsonMapper.ToJson(customData), placementID);
- }
- public static void showGDPRAuth()
- {
- client.showGDPRAuth();
- }
- public static void showGDPRConsentDialog(ATConsentDismissListener listener)
- {
- client.showGDPRConsentDialog(listener);
- }
- public static void setLogDebug(bool isDebug)
- {
- client.setLogDebug(isDebug);
- ATLogger.IsDebug = isDebug;
- }
- public static void addNetworkGDPRInfo(int networkType, Dictionary<string,object> dictionary)
- {
- client.addNetworkGDPRInfo(networkType, JsonMapper.ToJson(dictionary));
- }
- public static void deniedUploadDeviceInfo(string[] deniedInfo)
- {
- if (deniedInfo != null && deniedInfo.Length > 0)
- {
- string deniedString = JsonMapper.ToJson(deniedInfo);
- client.deniedUploadDeviceInfo(deniedString);
- Debug.Log("deniedUploadDeviceInfo, deniedInfo === " + deniedString);
- }
- else
- {
- Debug.Log("deniedUploadDeviceInfo, deniedInfo = null");
- }
-
- }
- private static IATSDKAPIClient GetATSDKAPIClient(){
- Debug.Log("GetATSDKAPIClient");
- return AnyThinkAds.ATAdsClientFactory.BuildSDKAPIClient();
- }
- public static void setExcludeBundleIdArray(string[] bundleIds)
- {
- if (bundleIds != null && bundleIds.Length > 0)
- {
- string bundleIdsString = JsonMapper.ToJson(bundleIds);
- Debug.Log("setExcludeBundleIdArray, bundleIdsString === " + bundleIdsString);
- client.setExcludeBundleIdArray(bundleIdsString);
- }
- else
- {
- Debug.Log("setExcludeBundleIdArray, bundleIdsString = null");
- }
- }
- public static void setExcludeAdSourceIdArrayForPlacementID(string placementID, string[] adSourceIds)
- {
- if (adSourceIds != null && adSourceIds.Length > 0)
- {
- string adSourceIdsString = JsonMapper.ToJson(adSourceIds);
- Debug.Log("setExcludeAdSourceIdArrayForPlacementID, adSourceIdsString === " + adSourceIdsString);
- client.setExcludeAdSourceIdArrayForPlacementID(placementID, adSourceIdsString);
- }
- else
- {
- Debug.Log("setExcludeAdSourceIdArrayForPlacementID, adSourceIdsString = null");
- }
- }
- public static void setSDKArea(int area)
- {
- client.setSDKArea(area);
- }
- public static void getArea(ATGetAreaListener listener)
- {
- client.getArea(listener);
- }
- public static void setWXStatus(bool install)
- {
- client.setWXStatus(install);
- }
- public static void setLocation(double longitude, double latitude)
- {
- client.setLocation(longitude, latitude);
- }
- }
- }
|