You've already forked Commercialization.topon
update 1.1.25
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AnyThinkAds.Api;
|
||||
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATAreaListener : AndroidJavaProxy
|
||||
{
|
||||
ATGetAreaListener mListener;
|
||||
public ATAreaListener(ATGetAreaListener listener): base("com.anythink.unitybridge.sdkinit.AreaCallbackListener")
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
|
||||
public void onResultCallback(string area)
|
||||
{
|
||||
if (mListener != null)
|
||||
{
|
||||
mListener.onArea(area);
|
||||
}
|
||||
}
|
||||
|
||||
public void onErrorCallback(string s)
|
||||
{
|
||||
if (mListener != null)
|
||||
{
|
||||
mListener.onError(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fff5148ee5b5148b1b875749d5f2639e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
314
AnyThinkPlugin/AnyThinkAds/Platform/Android/ATBannerAdClient.cs
Normal file
314
AnyThinkPlugin/AnyThinkAds/Platform/Android/ATBannerAdClient.cs
Normal file
@@ -0,0 +1,314 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
#pragma warning disable 0067
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATBannerAdClient : AndroidJavaProxy, IATBannerAdClient
|
||||
{
|
||||
|
||||
private Dictionary<string, AndroidJavaObject> bannerHelperMap = new Dictionary<string, AndroidJavaObject>();
|
||||
|
||||
|
||||
private ATBannerAdListener anyThinkListener;
|
||||
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
|
||||
// triggers when a banner ad has failed to load
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
|
||||
// triggers when a banner ad generates an impression
|
||||
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
|
||||
|
||||
// triggers when the user clicks a banner ad
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
|
||||
// triggers when the ad refreshes
|
||||
public event EventHandler<ATAdEventArgs> onAdAutoRefreshEvent;
|
||||
|
||||
// triggers when the ad fails to auto refresh
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdAutoRefreshFailureEvent;
|
||||
|
||||
// triggers when the banner ad is closed
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
|
||||
// triggers when the users closes the ad via the button
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseButtonTappedEvent;
|
||||
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
|
||||
public ATBannerAdClient() : base("com.anythink.unitybridge.banner.BannerListener")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void loadBannerAd(string placementId, string mapJson)
|
||||
{
|
||||
|
||||
//如果不存在则直接创建对应广告位的helper
|
||||
if(!bannerHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
AndroidJavaObject bannerHelper = new AndroidJavaObject(
|
||||
"com.anythink.unitybridge.banner.BannerHelper", this);
|
||||
bannerHelper.Call("initBanner", placementId);
|
||||
bannerHelperMap.Add(placementId, bannerHelper);
|
||||
Debug.Log("ATBannerAdClient : no exit helper ,create helper ");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Debug.Log("ATBannerAdClient : loadBannerAd ");
|
||||
bannerHelperMap[placementId].Call("loadBannerAd", mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATBannerAdClient : error."+e.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId)
|
||||
{
|
||||
string adStatusJsonString = "";
|
||||
Debug.Log("ATBannerAdClient : checkAdStatus....");
|
||||
try
|
||||
{
|
||||
if (bannerHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
adStatusJsonString = bannerHelperMap[placementId].Call<string>("checkAdStatus");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATBannerAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
string validAdCachesString = "";
|
||||
Debug.Log("ATBannerAdClient : getValidAdCaches....");
|
||||
try
|
||||
{
|
||||
if (bannerHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
validAdCachesString = bannerHelperMap[placementId].Call<string>("getValidAdCaches");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATBannerAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return validAdCachesString;
|
||||
}
|
||||
|
||||
|
||||
public void setListener(ATBannerAdListener listener)
|
||||
{
|
||||
anyThinkListener = listener;
|
||||
}
|
||||
|
||||
|
||||
public void showBannerAd(string placementId, string position, string mapJson)
|
||||
{
|
||||
Debug.Log("ATBannerAdClient : showBannerAd by position" );
|
||||
//todo
|
||||
try
|
||||
{
|
||||
if (bannerHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
this.bannerHelperMap[placementId].Call("showBannerAd", position, mapJson);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATBannerAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void showBannerAd(string placementId, ATRect rect, string mapJson)
|
||||
{
|
||||
Debug.Log("ATBannerAdClient : showBannerAd " );
|
||||
|
||||
try{
|
||||
if (bannerHelperMap.ContainsKey(placementId)) {
|
||||
this.bannerHelperMap[placementId].Call ("showBannerAd", rect.x, rect.y, rect.width, rect.height, mapJson);
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATBannerAdClient : error."+e.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanBannerAd(string placementId)
|
||||
{
|
||||
|
||||
Debug.Log("ATBannerAdClient : cleanBannerAd" );
|
||||
|
||||
try{
|
||||
if (bannerHelperMap.ContainsKey(placementId)) {
|
||||
this.bannerHelperMap[placementId].Call ("cleanBannerAd");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATBannerAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void hideBannerAd(string placementId)
|
||||
{
|
||||
Debug.Log("ATBannerAdClient : hideBannerAd");
|
||||
|
||||
try
|
||||
{
|
||||
if (bannerHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
this.bannerHelperMap[placementId].Call("hideBannerAd");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATBannerAdClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
//针对已有的进行展示,没有就调用该方法无效
|
||||
public void showBannerAd(string placementId)
|
||||
{
|
||||
Debug.Log("ATBannerAdClient : showBannerAd ");
|
||||
|
||||
try
|
||||
{
|
||||
if (bannerHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
this.bannerHelperMap[placementId].Call("showBannerAd");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATBannerAdClient : error." + e.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanCache(string placementId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//广告加载成功
|
||||
public void onBannerLoaded(string placementId)
|
||||
{
|
||||
Debug.Log("onBannerLoaded...unity3d.");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
}
|
||||
|
||||
//广告加载失败
|
||||
public void onBannerFailed(string placementId,string code, string error)
|
||||
{
|
||||
Debug.Log("onBannerFailed...unity3d.");
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
//广告点击
|
||||
public void onBannerClicked(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onBannerClicked...unity3d.");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
//广告展示
|
||||
public void onBannerShow(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onBannerShow...unity3d.");
|
||||
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
//广告关闭
|
||||
public void onBannerClose(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onBannerClose...unity3d.");
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
//广告关闭
|
||||
public void onBannerAutoRefreshed(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onBannerAutoRefreshed...unity3d.");
|
||||
onAdAutoRefreshEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
//广告自动刷新失败
|
||||
public void onBannerAutoRefreshFail(string placementId, string code, string msg)
|
||||
{
|
||||
Debug.Log("onBannerAutoRefreshFail...unity3d.");
|
||||
onAdAutoRefreshFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, msg));
|
||||
}
|
||||
|
||||
// Adsource Listener
|
||||
public void onAdSourceBiddingAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
|
||||
public void onAdSourceAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fca17c67aed8f49a89234a09fe2a7ed4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,93 @@
|
||||
using UnityEngine;
|
||||
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATDownloadClient : AndroidJavaProxy,IATDownloadClient
|
||||
{
|
||||
|
||||
private AndroidJavaObject downloadHelper;
|
||||
|
||||
|
||||
private ATDownloadAdListener anyThinkListener;
|
||||
|
||||
public ATDownloadClient() : base("com.anythink.unitybridge.download.DownloadListener")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void setListener(ATDownloadAdListener listener)
|
||||
{
|
||||
Debug.Log("ATDownloadClient : setListener");
|
||||
anyThinkListener = listener;
|
||||
|
||||
if (downloadHelper == null)
|
||||
{
|
||||
downloadHelper = new AndroidJavaObject(
|
||||
"com.anythink.unitybridge.download.DownloadHelper", this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void onDownloadStart(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
|
||||
{
|
||||
Debug.Log("onDownloadStart...unity3d.");
|
||||
if(anyThinkListener != null){
|
||||
anyThinkListener.onDownloadStart(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onDownloadUpdate(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
|
||||
{
|
||||
Debug.Log("onDownloadUpdate...unity3d.");
|
||||
if (anyThinkListener != null)
|
||||
{
|
||||
anyThinkListener.onDownloadUpdate(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onDownloadPause(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
|
||||
{
|
||||
Debug.Log("onDownloadPause...unity3d.");
|
||||
if (anyThinkListener != null)
|
||||
{
|
||||
anyThinkListener.onDownloadPause(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onDownloadFinish(string placementId, string callbackJson, long totalBytes, string fileName, string appName)
|
||||
{
|
||||
Debug.Log("onDownloadFinish...unity3d.");
|
||||
if (anyThinkListener != null)
|
||||
{
|
||||
anyThinkListener.onDownloadFinish(placementId, new ATCallbackInfo(callbackJson), totalBytes, fileName, appName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onDownloadFail(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
|
||||
{
|
||||
Debug.Log("onDownloadFail...unity3d.");
|
||||
if (anyThinkListener != null)
|
||||
{
|
||||
anyThinkListener.onDownloadFail(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onInstalled(string placementId, string callbackJson, string fileName, string appName)
|
||||
{
|
||||
Debug.Log("onInstalled...unity3d.");
|
||||
if (anyThinkListener != null)
|
||||
{
|
||||
anyThinkListener.onInstalled(placementId, new ATCallbackInfo(callbackJson), fileName, appName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a6098e9d114f4f3584530c7a5361c42
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AnyThinkAds.Api;
|
||||
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATGDPRConsentDismissListener : AndroidJavaProxy
|
||||
{
|
||||
ATConsentDismissListener mListener;
|
||||
public ATGDPRConsentDismissListener(ATConsentDismissListener listener): base("com.anythink.unitybridge.sdkinit.SDKConsentDismissListener")
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
public void onConsentDismiss()
|
||||
{
|
||||
if (mListener != null)
|
||||
{
|
||||
mListener.onConsentDismiss();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2853fd494219b478ba619568a7691609
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,427 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATInterstitialAdClient : AndroidJavaProxy,IATInterstitialAdClient
|
||||
{
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdShowEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdShowFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
|
||||
private Dictionary<string, AndroidJavaObject> interstitialHelperMap = new Dictionary<string, AndroidJavaObject>();
|
||||
|
||||
//private AndroidJavaObject videoHelper;
|
||||
private ATInterstitialAdListener anyThinkListener;
|
||||
|
||||
private AndroidJavaObject interstitialAutoAdHelper;
|
||||
|
||||
public ATInterstitialAdClient() : base("com.anythink.unitybridge.interstitial.InterstitialListener")
|
||||
{
|
||||
interstitialAutoAdHelper = new AndroidJavaObject("com.anythink.unitybridge.interstitial.InterstitialAutoAdHelper", this);
|
||||
}
|
||||
|
||||
|
||||
public void loadInterstitialAd(string placementId, string mapJson)
|
||||
{
|
||||
|
||||
//如果不存在则直接创建对应广告位的helper
|
||||
if(!interstitialHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
AndroidJavaObject videoHelper = new AndroidJavaObject(
|
||||
"com.anythink.unitybridge.interstitial.InterstitialHelper", this);
|
||||
videoHelper.Call("initInterstitial", placementId);
|
||||
interstitialHelperMap.Add(placementId, videoHelper);
|
||||
Debug.Log("ATInterstitialAdClient : no exit helper ,create helper ");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Debug.Log("ATInterstitialAdClient : loadInterstitialAd ");
|
||||
interstitialHelperMap[placementId].Call("loadInterstitialAd", mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setListener(ATInterstitialAdListener listener)
|
||||
{
|
||||
anyThinkListener = listener;
|
||||
}
|
||||
|
||||
public bool hasInterstitialAdReady(string placementId)
|
||||
{
|
||||
bool isready = false;
|
||||
Debug.Log ("ATInterstitialAdClient : hasAdReady....");
|
||||
try{
|
||||
if (interstitialHelperMap.ContainsKey(placementId)) {
|
||||
isready = interstitialHelperMap[placementId].Call<bool> ("isAdReady");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
|
||||
}
|
||||
return isready;
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId)
|
||||
{
|
||||
string adStatusJsonString = "";
|
||||
Debug.Log("ATInterstitialAdClient : checkAdStatus....");
|
||||
try
|
||||
{
|
||||
if (interstitialHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
adStatusJsonString = interstitialHelperMap[placementId].Call<string>("checkAdStatus");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATInterstitialAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
|
||||
Debug.Log("ATInterstitialAdClient : entryScenarioWithPlacementID....");
|
||||
try
|
||||
{
|
||||
if (interstitialHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
interstitialHelperMap[placementId].Call("entryAdScenario", scenarioID);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATInterstitialAdClient entryScenarioWithPlacementID: error." + e.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
string validAdCachesString = "";
|
||||
Debug.Log("ATNativeAdClient : getValidAdCaches....");
|
||||
try
|
||||
{
|
||||
if (interstitialHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
validAdCachesString = interstitialHelperMap[placementId].Call<string>("getValidAdCaches");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATNativeAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return validAdCachesString;
|
||||
}
|
||||
|
||||
public void showInterstitialAd(string placementId, string jsonmap)
|
||||
{
|
||||
Debug.Log("ATInterstitialAdClient : showAd " );
|
||||
|
||||
try{
|
||||
if (interstitialHelperMap.ContainsKey(placementId)) {
|
||||
this.interstitialHelperMap[placementId].Call ("showInterstitialAd", jsonmap);
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void cleanCache(string placementId)
|
||||
{
|
||||
|
||||
Debug.Log("ATInterstitialAdClient : clean" );
|
||||
|
||||
try{
|
||||
if (interstitialHelperMap.ContainsKey(placementId)) {
|
||||
this.interstitialHelperMap[placementId].Call ("clean");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void onApplicationForces(string placementId)
|
||||
{
|
||||
Debug.Log ("onApplicationForces.... ");
|
||||
try{
|
||||
if (interstitialHelperMap.ContainsKey(placementId)) {
|
||||
this.interstitialHelperMap[placementId].Call ("onResume");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void onApplicationPasue(string placementId)
|
||||
{
|
||||
Debug.Log ("onApplicationPasue.... ");
|
||||
try{
|
||||
if (interstitialHelperMap.ContainsKey(placementId)) {
|
||||
this.interstitialHelperMap[placementId].Call ("onPause");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
//广告加载成功
|
||||
public void onInterstitialAdLoaded(string placementId)
|
||||
{
|
||||
Debug.Log("onInterstitialAdLoaded...unity3d.");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
}
|
||||
|
||||
//广告加载失败
|
||||
public void onInterstitialAdLoadFail(string placementId,string code, string error)
|
||||
{
|
||||
Debug.Log("onInterstitialAdFailed...unity3d.");
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
//开始播放
|
||||
public void onInterstitialAdVideoStart(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onInterstitialAdPlayStart...unity3d.");
|
||||
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
//结束播放
|
||||
public void onInterstitialAdVideoEnd(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onInterstitialAdPlayEnd...unity3d.");
|
||||
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
//播放失败
|
||||
public void onInterstitialAdVideoError(string placementId,string code, string error)
|
||||
{
|
||||
Debug.Log("onInterstitialAdPlayFailed...unity3d.");
|
||||
onAdVideoFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
//展示失败
|
||||
public void OnInterstitialAdFailedToShow(string placementID) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdFailedToShow()");
|
||||
onAdShowFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, "-1", "Failed to show video ad"));
|
||||
}
|
||||
|
||||
|
||||
//广告关闭
|
||||
public void onInterstitialAdClose(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onInterstitialAdClosed...unity3d.");
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
//广告点击
|
||||
public void onInterstitialAdClicked(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onInterstitialAdClicked...unity3d.");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onInterstitialAdShow(string placementId, string callbackJson){
|
||||
Debug.Log("onInterstitialAdShow...unity3d.");
|
||||
onAdShowEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
// Adsource Listener
|
||||
public void onAdSourceBiddingAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
|
||||
public void onAdSourceAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
|
||||
// Auto
|
||||
public void addAutoLoadAdPlacementID(string[] placementIDList){
|
||||
Debug.Log("Unity: ATInterstitialAdClient:addAutoLoadAdPlacementID()" + JsonMapper.ToJson(placementIDList));
|
||||
try
|
||||
{
|
||||
interstitialAutoAdHelper.Call("addPlacementIds", JsonMapper.ToJson(placementIDList));
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATInterstitialAdClient addAutoLoadAdPlacementID: error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAutoLoadAdPlacementID(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:removeAutoLoadAdPlacementID()");
|
||||
try
|
||||
{
|
||||
interstitialAutoAdHelper.Call("removePlacementIds", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATInterstitialAdClient removeAutoLoadAdPlacementID: error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public bool autoLoadInterstitialAdReadyForPlacementID(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:autoLoadInterstitialAdReadyForPlacementID()");
|
||||
bool isready = false;
|
||||
try
|
||||
{
|
||||
isready = interstitialAutoAdHelper.Call<bool>("isAdReady", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATInterstitialAdClient:autoLoadInterstitialAdReadyForPlacementID( : error." + e.Message);
|
||||
}
|
||||
return isready;
|
||||
}
|
||||
public string getAutoValidAdCaches(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:getAutoValidAdCaches()");
|
||||
string adStatusJsonString = "";
|
||||
try
|
||||
{
|
||||
adStatusJsonString = interstitialAutoAdHelper.Call<string>("getValidAdCaches", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATInterstitialAdClient:getAutoValidAdCaches() : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
public void setAutoLocalExtra(string placementId, string mapJson)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:setAutoLocalExtra()");
|
||||
try
|
||||
{
|
||||
interstitialAutoAdHelper.Call("setAdExtraData", placementId, mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATInterstitialAdClient:setAutoLocalExtra() : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:entryAutoAdScenarioWithPlacementID()");
|
||||
try
|
||||
{
|
||||
interstitialAutoAdHelper.Call("entryAdScenario", placementId, scenarioID);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATInterstitialAdClient:entryAutoAdScenarioWithPlacementID() : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void showAutoAd(string placementId, string mapJson)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient::showAutoAd()");
|
||||
try
|
||||
{
|
||||
interstitialAutoAdHelper.Call("show", placementId, mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATInterstitialAdClient:showAutoAd() : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public string checkAutoAdStatus(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:checkAutoAdStatus() : checkAutoAdStatus....");
|
||||
string adStatusJsonString = "";
|
||||
try
|
||||
{
|
||||
adStatusJsonString = interstitialAutoAdHelper.Call<string>("checkAdStatus", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATInterstitialAdClient:checkAutoAdStatus() : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9247d5c90a80948d0b6259c8b13b7556
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
54
AnyThinkPlugin/AnyThinkAds/Platform/Android/ATMsgTools.cs
Normal file
54
AnyThinkPlugin/AnyThinkAds/Platform/Android/ATMsgTools.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
#if UNITY_ANDROID
|
||||
|
||||
public class ATMsgTools
|
||||
{
|
||||
private AndroidJavaObject _Plugin;
|
||||
|
||||
public ATMsgTools ()
|
||||
{
|
||||
try{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
return;
|
||||
|
||||
_Plugin = new AndroidJavaObject ("com.anythink.unitybridge.MsgTools");
|
||||
|
||||
}catch(System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void printLogI (string msg)
|
||||
{
|
||||
try{
|
||||
|
||||
_Plugin.Call ("printLogI",msg);
|
||||
}catch(System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void printMsg (string msg)
|
||||
{
|
||||
try{
|
||||
_Plugin.Call ("pirntMsg",msg);
|
||||
}catch(System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f34d69c411401435c839f09004815591
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
342
AnyThinkPlugin/AnyThinkAds/Platform/Android/ATNativeAdClient.cs
Normal file
342
AnyThinkPlugin/AnyThinkAds/Platform/Android/ATNativeAdClient.cs
Normal file
@@ -0,0 +1,342 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATNativeAdClient : AndroidJavaProxy, IATNativeAdClient
|
||||
{
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
|
||||
private Dictionary<string, AndroidJavaObject> nativeAdHelperMap = new Dictionary<string, AndroidJavaObject>();
|
||||
private ATNativeAdListener mlistener;
|
||||
|
||||
public ATNativeAdClient(): base("com.anythink.unitybridge.nativead.NativeListener")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void loadNativeAd(string placementId, string mapJson)
|
||||
{
|
||||
Debug.Log ("loadNativeAd....jsonmap:"+mapJson);
|
||||
if(!nativeAdHelperMap.ContainsKey(placementId)){
|
||||
AndroidJavaObject nativeHelper = new AndroidJavaObject(
|
||||
"com.anythink.unitybridge.nativead.NativeHelper", this);
|
||||
nativeHelper.Call("initNative", placementId);
|
||||
nativeAdHelperMap.Add(placementId, nativeHelper);
|
||||
}
|
||||
try{
|
||||
if (nativeAdHelperMap.ContainsKey(placementId)) {
|
||||
nativeAdHelperMap[placementId].Call ("loadNative",mapJson);
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATNativeAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool hasAdReady(string placementId)
|
||||
{
|
||||
bool isready = false;
|
||||
Debug.Log ("hasAdReady....");
|
||||
try{
|
||||
if (nativeAdHelperMap.ContainsKey(placementId)) {
|
||||
isready = nativeAdHelperMap[placementId].Call<bool> ("isAdReady");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATNativeAdClient : error."+e.Message);
|
||||
}
|
||||
return isready;
|
||||
}
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
|
||||
Debug.Log("ATNativeAdClient : entryScenarioWithPlacementID....");
|
||||
try
|
||||
{
|
||||
if (nativeAdHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
nativeAdHelperMap[placementId].Call("entryAdScenario", scenarioID);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATNativeAdClient entryScenarioWithPlacementID: error." + e.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId)
|
||||
{
|
||||
string adStatusJsonString = "";
|
||||
Debug.Log("ATNativeAdClient : checkAdStatus....");
|
||||
try
|
||||
{
|
||||
if (nativeAdHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
adStatusJsonString = nativeAdHelperMap[placementId].Call<string>("checkAdStatus");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATNativeAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
string validAdCachesString = "";
|
||||
Debug.Log("ATNativeAdClient : getValidAdCaches....");
|
||||
try
|
||||
{
|
||||
if (nativeAdHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
validAdCachesString = nativeAdHelperMap[placementId].Call<string>("getValidAdCaches");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATNativeAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return validAdCachesString;
|
||||
}
|
||||
|
||||
public void setListener(ATNativeAdListener listener)
|
||||
{
|
||||
mlistener = listener;
|
||||
}
|
||||
|
||||
public void renderAdToScene(string placementId, ATNativeAdView anyThinkNativeAdView, string mapJson)
|
||||
{
|
||||
string showconfig = anyThinkNativeAdView.toJSON ();
|
||||
//暂未实现 show
|
||||
Debug.Log ("renderAdToScene....showconfig >>>:"+showconfig);
|
||||
try{
|
||||
if (nativeAdHelperMap.ContainsKey(placementId)) {
|
||||
nativeAdHelperMap[placementId].Call ("show",showconfig, mapJson);
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
Debug.Log ("ATNativeAdClient : error."+e.Message);
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanAdView(string placementId, ATNativeAdView anyThinkNativeAdView)
|
||||
{
|
||||
//
|
||||
Debug.Log ("cleanAdView.... ");
|
||||
try{
|
||||
|
||||
if (nativeAdHelperMap.ContainsKey(placementId)) {
|
||||
nativeAdHelperMap[placementId].Call ("cleanView");
|
||||
}
|
||||
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATNativeAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void onApplicationForces(string placementId, ATNativeAdView anyThinkNativeAdView)
|
||||
{
|
||||
|
||||
|
||||
Debug.Log ("onApplicationForces.... ");
|
||||
try{
|
||||
|
||||
if (nativeAdHelperMap.ContainsKey(placementId)) {
|
||||
nativeAdHelperMap[placementId].Call ("onResume");
|
||||
}
|
||||
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATNativeAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onApplicationPasue(string placementId, ATNativeAdView anyThinkNativeAdView)
|
||||
{
|
||||
|
||||
Debug.Log ("onApplicationPasue.... ");
|
||||
try{
|
||||
|
||||
|
||||
if (nativeAdHelperMap.ContainsKey(placementId)) {
|
||||
nativeAdHelperMap[placementId].Call ("onPause");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATNativeAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanCache(string placementId)
|
||||
{
|
||||
Debug.Log ("cleanCache....");
|
||||
try{
|
||||
if (nativeAdHelperMap.ContainsKey(placementId)) {
|
||||
nativeAdHelperMap[placementId].Call ("clean");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATNativeAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告展示回调
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public void onAdImpressed(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdImpressed...unity3d.");
|
||||
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告点击回调
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public void onAdClicked(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdClicked...unity3d.");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告视频开始回调
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public void onAdVideoStart(string placementId)
|
||||
{
|
||||
Debug.Log("onAdVideoStart...unity3d.");
|
||||
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告视频结束回调
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public void onAdVideoEnd(string placementId)
|
||||
{
|
||||
Debug.Log("onAdVideoEnd...unity3d.");
|
||||
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementId,""));
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告视频进度回调
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public void onAdVideoProgress(string placementId,int progress)
|
||||
{
|
||||
Debug.Log("onAdVideoProgress...progress[" + progress + "]");
|
||||
onAdVideoProgressEvent?.Invoke(this, new ATAdProgressEventArgs(placementId,"",progress));
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告视频进度回调
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public void onAdCloseButtonClicked(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdCloseButtonClicked...unity3d");
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 广告加载成功
|
||||
*/
|
||||
public void onNativeAdLoaded(string placementId)
|
||||
{
|
||||
Debug.Log("onNativeAdLoaded...unity3d.");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId,""));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告加载失败
|
||||
*/
|
||||
public void onNativeAdLoadFail(string placementId,string code, string msg)
|
||||
{
|
||||
Debug.Log("onNativeAdLoadFail...unity3d. code:" + code + " msg:" + msg);
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,code,msg));
|
||||
}
|
||||
|
||||
// Adsource Listener
|
||||
public void onAdSourceBiddingAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,callbackJson,code,error));
|
||||
}
|
||||
|
||||
public void onAdSourceAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,callbackJson,code,error));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41e3b7583470c40659c82050279f5635
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
#pragma warning disable 0067
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATNativeBannerAdClient :IATNativeBannerAdClient
|
||||
{
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
public ATNativeBannerAdClient() {
|
||||
|
||||
}
|
||||
|
||||
public void loadAd(string placementId, string mapJson) {
|
||||
|
||||
}
|
||||
|
||||
public bool adReady(string placementId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setListener(ATNativeBannerAdListener listener) {
|
||||
|
||||
}
|
||||
|
||||
public void showAd(string placementId, ATRect rect, Dictionary<string, string> pairs) {
|
||||
|
||||
}
|
||||
|
||||
public void removeAd(string placementId) {
|
||||
|
||||
}
|
||||
|
||||
public void onAdLoaded(string placementId) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdLoaded()");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
}
|
||||
|
||||
public void onAdLoadFail(string placementId, string code, string message) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdLoadFail()");
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, "", code, message));
|
||||
|
||||
}
|
||||
|
||||
public void onAdImpressed(string placementId, string callbackJson) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdImpressed()");
|
||||
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
|
||||
}
|
||||
|
||||
public void onAdClicked(string placementId, string callbackJson) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdClicked()");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
public void onAdAutoRefresh(string placementId, string callbackJson) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdAutoRefresh()");
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
|
||||
}
|
||||
|
||||
public void onAdAutoRefreshFailure(string placementId, string code, string message) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdAutoRefreshFailure()");
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, "", code, message));
|
||||
|
||||
}
|
||||
|
||||
public void onAdCloseButtonClicked(string placementId) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdCloseButtonClicked()");
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 265f9ebdd83c3480db5c82c4b98b3a6c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AnyThinkAds.Api;
|
||||
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATNetTrafficListener : AndroidJavaProxy
|
||||
{
|
||||
ATGetUserLocationListener mListener;
|
||||
public ATNetTrafficListener(ATGetUserLocationListener listener): base("com.anythink.unitybridge.sdkinit.SDKEUCallbackListener")
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
|
||||
public void onResultCallback(bool isEu)
|
||||
{
|
||||
if (mListener != null)
|
||||
{
|
||||
if (isEu)
|
||||
{
|
||||
mListener.didGetUserLocation(ATSDKAPI.kATUserLocationInEU);
|
||||
}
|
||||
else
|
||||
{
|
||||
mListener.didGetUserLocation(ATSDKAPI.kATUserLocationOutOfEU);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onErrorCallback(string s)
|
||||
{
|
||||
if (mListener != null)
|
||||
{
|
||||
mListener.didGetUserLocation(ATSDKAPI.kATUserLocationUnknown);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f25fcf4e04d1f43b287d19ad456699b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,416 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATRewardedVideoAdClient : AndroidJavaProxy,IATRewardedVideoAdClient
|
||||
{
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
|
||||
public event EventHandler<ATAdRewardEventArgs> onAdVideoCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onRewardEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onPlayAgainStart;
|
||||
public event EventHandler<ATAdEventArgs> onPlayAgainEnd;
|
||||
public event EventHandler<ATAdErrorEventArgs> onPlayAgainFailure;
|
||||
public event EventHandler<ATAdEventArgs> onPlayAgainClick;
|
||||
public event EventHandler<ATAdEventArgs> onPlayAgainReward;
|
||||
|
||||
|
||||
private Dictionary<string, AndroidJavaObject> videoHelperMap = new Dictionary<string, AndroidJavaObject>();
|
||||
|
||||
private AndroidJavaObject videoAutoAdHelper;
|
||||
|
||||
//private AndroidJavaObject videoHelper;
|
||||
private ATRewardedVideoListener anyThinkListener;
|
||||
|
||||
public ATRewardedVideoAdClient() : base("com.anythink.unitybridge.videoad.VideoListener")
|
||||
{
|
||||
videoAutoAdHelper = new AndroidJavaObject("com.anythink.unitybridge.videoad.VideoAutoAdHelper", this);
|
||||
}
|
||||
|
||||
|
||||
public void loadVideoAd(string placementId, string mapJson)
|
||||
{
|
||||
|
||||
if(!videoHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
AndroidJavaObject videoHelper = new AndroidJavaObject(
|
||||
"com.anythink.unitybridge.videoad.VideoHelper", this);
|
||||
videoHelper.Call("initVideo", placementId);
|
||||
videoHelperMap.Add(placementId, videoHelper);
|
||||
Debug.Log("ATRewardedVideoAdClient : no exit helper ,create helper ");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Debug.Log("ATRewardedVideoAdClient : loadVideoAd ");
|
||||
videoHelperMap[placementId].Call("fillVideo", mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATRewardedVideoAdClient : error."+e.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setListener(ATRewardedVideoListener listener)
|
||||
{
|
||||
anyThinkListener = listener;
|
||||
}
|
||||
|
||||
public bool hasAdReady(string placementId)
|
||||
{
|
||||
bool isready = false;
|
||||
Debug.Log ("ATRewardedVideoAdClient : hasAdReady....");
|
||||
try{
|
||||
if (videoHelperMap.ContainsKey(placementId)) {
|
||||
isready = videoHelperMap[placementId].Call<bool> ("isAdReady");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATRewardedVideoAdClient : error."+e.Message);
|
||||
}
|
||||
return isready;
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId)
|
||||
{
|
||||
string adStatusJsonString = "";
|
||||
Debug.Log("ATRewardedVideoAdClient : checkAdStatus....");
|
||||
try
|
||||
{
|
||||
if (videoHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
adStatusJsonString = videoHelperMap[placementId].Call<string>("checkAdStatus");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATRewardedVideoAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
|
||||
Debug.Log("ATRewardedVideoAdClient : entryScenarioWithPlacementID....");
|
||||
try
|
||||
{
|
||||
if (videoHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
videoHelperMap[placementId].Call("entryAdScenario", scenarioID);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATRewardedVideoAdClient entryScenarioWithPlacementID: error." + e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
string validAdCachesString = "";
|
||||
Debug.Log("ATNativeAdClient : getValidAdCaches....");
|
||||
try
|
||||
{
|
||||
if (videoHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
validAdCachesString = videoHelperMap[placementId].Call<string>("getValidAdCaches");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATNativeAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return validAdCachesString;
|
||||
}
|
||||
|
||||
public void showAd(string placementId, string scenario)
|
||||
{
|
||||
Debug.Log("ATRewardedVideoAdClient : showAd " );
|
||||
|
||||
try{
|
||||
if (videoHelperMap.ContainsKey(placementId)) {
|
||||
this.videoHelperMap[placementId].Call ("showVideo", scenario);
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATRewardedVideoAdClient : error."+e.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void onRewardedVideoAdLoaded(string placementId)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdLoaded...unity3d.");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
}
|
||||
|
||||
|
||||
public void onRewardedVideoAdFailed(string placementId,string code, string error)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdFailed...unity3d.");
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
|
||||
public void onRewardedVideoAdPlayStart(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdPlayStart...unity3d.");
|
||||
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
|
||||
public void onRewardedVideoAdPlayEnd(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdPlayEnd...unity3d.");
|
||||
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
|
||||
public void onRewardedVideoAdPlayFailed(string placementId,string code, string error)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdPlayFailed...unity3d.");
|
||||
onAdVideoFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
public void onRewardedVideoAdClosed(string placementId,bool isRewarded, string callbackJson)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdClosed...unity3d.");
|
||||
onAdVideoCloseEvent?.Invoke(this, new ATAdRewardEventArgs(placementId, callbackJson, isRewarded));
|
||||
}
|
||||
|
||||
public void onRewardedVideoAdPlayClicked(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdPlayClicked...unity3d.");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void onReward(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onReward...unity3d.");
|
||||
onRewardEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
|
||||
public void onRewardedVideoAdAgainPlayStart(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdAgainPlayStart...unity3d.");
|
||||
onPlayAgainStart?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onRewardedVideoAdAgainPlayEnd(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdAgainPlayEnd...unity3d.");
|
||||
onPlayAgainEnd?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
|
||||
public void onRewardedVideoAdAgainPlayFailed(string placementId, string code, string error)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdAgainPlayFailed...unity3d.");
|
||||
onPlayAgainFailure?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
|
||||
public void onRewardedVideoAdAgainPlayClicked(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdAgainPlayClicked...unity3d.");
|
||||
onPlayAgainClick?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void onAgainReward(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAgainReward...unity3d.");
|
||||
onPlayAgainReward?.Invoke(this, new ATAdRewardEventArgs(placementId, callbackJson, true));
|
||||
}
|
||||
|
||||
// Adsource Listener
|
||||
public void onAdSourceBiddingAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingAttempt...unity3d."+ placementId + "," + callbackJson);
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFilled...unity3d." + placementId + "," + callbackJson);
|
||||
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
public void onAdSourceAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFilled...unity3d." + placementId + "," + callbackJson);
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
onAdSourceLoadFailureEvent?.Invoke(this,new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
|
||||
// Auto
|
||||
public void addAutoLoadAdPlacementID(string[] placementIDList){
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:addAutoLoadAdPlacementID()" + JsonMapper.ToJson(placementIDList));
|
||||
try
|
||||
{
|
||||
videoAutoAdHelper.Call("addPlacementIds", JsonMapper.ToJson(placementIDList));
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient addAutoLoadAdPlacementID: error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAutoLoadAdPlacementID(string placementId) {
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:removeAutoLoadAdPlacementID()");
|
||||
try
|
||||
{
|
||||
videoAutoAdHelper.Call("removePlacementIds", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient removeAutoLoadAdPlacementID: error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public bool autoLoadRewardedVideoReadyForPlacementID(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:autoLoadRewardedVideoReadyForPlacementID()");
|
||||
bool isready = false;
|
||||
try
|
||||
{
|
||||
isready = videoAutoAdHelper.Call<bool>("isAdReady", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATRewardedVideoAdClient:autoLoadRewardedVideoReadyForPlacementID( : error." + e.Message);
|
||||
}
|
||||
return isready;
|
||||
}
|
||||
|
||||
public string getAutoValidAdCaches(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:getAutoValidAdCaches()");
|
||||
string adStatusJsonString = "";
|
||||
try
|
||||
{
|
||||
adStatusJsonString = videoAutoAdHelper.Call<string>("getValidAdCaches", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATRewardedVideoAdClient:getAutoValidAdCaches() : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
public void setAutoLocalExtra(string placementId, string mapJson)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:setAutoLocalExtra()");
|
||||
try
|
||||
{
|
||||
videoAutoAdHelper.Call("setAdExtraData", placementId, mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATRewardedVideoAdClient:setAutoLocalExtra() : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:entryAutoAdScenarioWithPlacementID()");
|
||||
try
|
||||
{
|
||||
videoAutoAdHelper.Call("entryAdScenario", placementId, scenarioID);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATRewardedVideoAdClient:entryAutoAdScenarioWithPlacementID() : error." + e.Message);
|
||||
}
|
||||
}
|
||||
public void showAutoAd(string placementId, string mapJson) {
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:showAutoAd()");
|
||||
try
|
||||
{
|
||||
videoAutoAdHelper.Call("show", placementId, mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:showAutoAd() : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public string checkAutoAdStatus(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:checkAutoAdStatus() : checkAutoAdStatus....");
|
||||
string adStatusJsonString = "";
|
||||
try
|
||||
{
|
||||
adStatusJsonString = videoAutoAdHelper.Call<string>("checkAdStatus", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:checkAutoAdStatus() : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0c4f48c3056641138671590135acb04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
390
AnyThinkPlugin/AnyThinkAds/Platform/Android/ATSDKAPIClient.cs
Normal file
390
AnyThinkPlugin/AnyThinkAds/Platform/Android/ATSDKAPIClient.cs
Normal file
@@ -0,0 +1,390 @@
|
||||
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() {
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("showDebuggerUI");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc261ca3c0936463c9d358ab5ade132d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
237
AnyThinkPlugin/AnyThinkAds/Platform/Android/ATSplashAdClient.cs
Normal file
237
AnyThinkPlugin/AnyThinkAds/Platform/Android/ATSplashAdClient.cs
Normal file
@@ -0,0 +1,237 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATSplashAdClient : AndroidJavaProxy, IATSplashAdClient
|
||||
{
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadTimeoutEvent;
|
||||
public event EventHandler<ATAdEventArgs> onDeeplinkEvent;
|
||||
public event EventHandler<ATAdEventArgs> onDownloadConfirmEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdShowEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdShowFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
|
||||
private Dictionary<string, AndroidJavaObject> splashHelperMap = new Dictionary<string, AndroidJavaObject>();
|
||||
private ATSplashAdListener splashAdListener;
|
||||
|
||||
private int fetchAdTimeout = 0;
|
||||
private string defaultAdSourceConfig;
|
||||
|
||||
public ATSplashAdClient() : base("com.anythink.unitybridge.splash.SplashListener")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private AndroidJavaObject getSplashHelper(string placementId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!splashHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
AndroidJavaObject splashHelper = new AndroidJavaObject(
|
||||
"com.anythink.unitybridge.splash.SplashHelper", this);
|
||||
splashHelper.Call("initSplash", placementId, fetchAdTimeout, defaultAdSourceConfig);
|
||||
splashHelperMap.Add(placementId, splashHelper);
|
||||
return splashHelper;
|
||||
} else {
|
||||
return splashHelperMap[placementId];
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
ATLogger.LogError("getSplashHelper() >>> error: {0}", e.Message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void loadSplashAd(string placementId, int fetchAdTimeout = 0, string defaultAdSourceConfig = "", string mapJson = "")
|
||||
{
|
||||
this.fetchAdTimeout = fetchAdTimeout;
|
||||
this.defaultAdSourceConfig = defaultAdSourceConfig;
|
||||
try
|
||||
{
|
||||
ATLogger.Log("loadSplashAd() >>> placementId: {0}", placementId);
|
||||
getSplashHelper(placementId).Call("loadAd", mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
ATLogger.LogError("loadSplashAd() >>> error: {0}", e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener(ATSplashAdListener listener)
|
||||
{
|
||||
this.splashAdListener = listener;
|
||||
}
|
||||
|
||||
public bool hasSplashAdReady(string placementId)
|
||||
{
|
||||
bool isAdReady = false;
|
||||
ATLogger.Log("hasSplashAdReady() >>> placementId: {0}", placementId);
|
||||
try
|
||||
{
|
||||
isAdReady = getSplashHelper(placementId).Call<bool>("isAdReady");
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
ATLogger.LogError("hasSplashAdReady() >>> error: {0}", e.Message);
|
||||
}
|
||||
return isAdReady;
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId)
|
||||
{
|
||||
string adStatusJsonString = "";
|
||||
ATLogger.Log("checkAdStatus() >>> placementId: {0}", placementId);
|
||||
try
|
||||
{
|
||||
adStatusJsonString = getSplashHelper(placementId).Call<string>("checkAdStatus");
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
ATLogger.LogError("checkAdStatus() >>> error: {0}", e.Message);
|
||||
}
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
public void showSplashAd(string placementId, string mapJson)
|
||||
{
|
||||
ATLogger.Log("showSplashAd() >>> placementId: {0}, mapJson: {1}", placementId, mapJson);
|
||||
try
|
||||
{
|
||||
getSplashHelper(placementId).Call("showAd", mapJson);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
ATLogger.LogError("showSplashAd() >>> error: {0}", e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
ATLogger.Log("getValidAdCaches() >>> placementId: {0}", placementId);
|
||||
string adString = "";
|
||||
try
|
||||
{
|
||||
adString = getSplashHelper(placementId).Call<string>("getValidAdCaches");
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
ATLogger.LogError("getValidAdCaches() >>> error: {0}", e.Message);
|
||||
}
|
||||
return adString;
|
||||
}
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID)
|
||||
{
|
||||
ATLogger.Log("entryScenarioWithPlacementID() >>> placementId: {0}, scenarioID: {1}", placementId, scenarioID);
|
||||
|
||||
try
|
||||
{
|
||||
getSplashHelper(placementId).Call<string>("entryAdScenario", scenarioID);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
ATLogger.LogError("entryScenarioWithPlacementID() >>> error: {0}", e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void onSplashAdLoad(String unitId, bool isTimeout)
|
||||
{
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(unitId, "", isTimeout));
|
||||
}
|
||||
|
||||
public void onSplashAdLoadTimeOut(String unitId)
|
||||
{
|
||||
onAdLoadTimeoutEvent?.Invoke(this, new ATAdEventArgs(unitId, "", true));
|
||||
}
|
||||
|
||||
public void onSplashAdLoadFailed(String unitId, String code, String msg)
|
||||
{
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(unitId, code, msg));
|
||||
}
|
||||
|
||||
public void onSplashAdShow(String unitId, String callbackJson)
|
||||
{
|
||||
onAdShowEvent?.Invoke(this, new ATAdEventArgs(unitId, callbackJson));
|
||||
}
|
||||
|
||||
public void onSplashAdClick(String unitId, String callbackJson)
|
||||
{
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(unitId, callbackJson));
|
||||
}
|
||||
|
||||
public void onSplashAdDismiss(String unitId, String callbackJson)
|
||||
{
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(unitId, callbackJson));
|
||||
}
|
||||
|
||||
public void onSplashAdDeeplinkCallback(String unitId, String callbackJson, bool isSuccess)
|
||||
{
|
||||
onDeeplinkEvent?.Invoke(this, new ATAdEventArgs(unitId, callbackJson, false, isSuccess));
|
||||
}
|
||||
|
||||
public void onSplashAdDownloadConfirm(String unitId, String callbackJson)
|
||||
{
|
||||
onDownloadConfirmEvent?.Invoke(this, new ATAdEventArgs(unitId, callbackJson));
|
||||
}
|
||||
|
||||
// Adsource Listener
|
||||
public void onAdSourceBiddingAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
ATLogger.Log("onAdSourceBiddingAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFilled(string placementId, string callbackJson)
|
||||
{
|
||||
ATLogger.Log("onAdSourceBiddingFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
ATLogger.Log("onAdSourceBiddingFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
|
||||
public void onAdSourceAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
ATLogger.Log("onAdSourceAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFilled(string placementId, string callbackJson)
|
||||
{
|
||||
ATLogger.Log("onAdSourceLoadFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
ATLogger.Log("onAdSourceLoadFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8dc4b2769444b40628c5504cccdcfae5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user