You've already forked Commercialization.topon
update 1.1.25
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
public class ATAdWrapper {
|
||||
public ATAdWrapper() {
|
||||
}
|
||||
|
||||
public static void InvokeCallback(string callback, Dictionary<string, object> msgDict) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9d4e438f52f846049aee82485de8569
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,219 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using AOT;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
using AnyThinkAds.iOS;
|
||||
using AnyThinkAds.Api;
|
||||
#pragma warning disable 0109
|
||||
public class ATBannerAdWrapper:ATAdWrapper {
|
||||
static private Dictionary<string, ATBannerAdClient> clients;
|
||||
static private string CMessaageReceiverClass = "ATBannerAdWrapper";
|
||||
|
||||
static public new void InvokeCallback(JsonData jsonData) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::InvokeCallback()");
|
||||
string extraJson = "";
|
||||
string callback = (string)jsonData["callback"];
|
||||
Dictionary<string, object> msgDict = JsonMapper.ToObject<Dictionary<string, object>>(jsonData["msg"].ToJson());
|
||||
JsonData msgJsonData = jsonData["msg"];
|
||||
IDictionary idic = (System.Collections.IDictionary)msgJsonData;
|
||||
|
||||
if (idic.Contains("extra")) {
|
||||
JsonData extraJsonDate = msgJsonData["extra"];
|
||||
if (extraJsonDate != null) {
|
||||
extraJson = msgJsonData["extra"].ToJson();
|
||||
}
|
||||
}
|
||||
|
||||
if (callback.Equals("OnBannerAdLoad")) {
|
||||
OnBannerAdLoad((string)msgDict["placement_id"]);
|
||||
} else if (callback.Equals("OnBannerAdLoadFail")) {
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
OnBannerAdLoadFail((string)msgDict["placement_id"], (string)errorMsg["code"], (string)errorMsg["reason"]);
|
||||
} else if (callback.Equals("OnBannerAdImpress")) {
|
||||
OnBannerAdImpress((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnBannerAdClick")) {
|
||||
OnBannerAdClick((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnBannerAdAutoRefresh")) {
|
||||
OnBannerAdAutoRefresh((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnBannerAdAutoRefreshFail")) {
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
OnBannerAdAutoRefreshFail((string)msgDict["placement_id"], (string)errorMsg["code"], (string)errorMsg["reason"]);
|
||||
} else if (callback.Equals("OnBannerAdClose")) {
|
||||
OnBannerAdClose((string)msgDict["placement_id"]);
|
||||
} else if (callback.Equals("OnBannerAdCloseButtonTapped")) {
|
||||
OnBannerAdCloseButtonTapped((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("startLoadingADSource")) {
|
||||
StartLoadingADSource((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("finishLoadingADSource")) {
|
||||
FinishLoadingADSource((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("failToLoadADSource")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
FailToLoadADSource((string)msgDict["placement_id"], extraJson,errorDict);
|
||||
}else if (callback.Equals("startBiddingADSource")) {
|
||||
StartBiddingADSource((string)msgDict["placement_id"], extraJson);
|
||||
|
||||
}else if (callback.Equals("finishBiddingADSource")) {
|
||||
FinishBiddingADSource((string)msgDict["placement_id"], extraJson);
|
||||
|
||||
}else if (callback.Equals("failBiddingADSource")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
FailBiddingADSource((string)msgDict["placement_id"],extraJson, errorDict);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static public void loadBannerAd(string placementID, string customData) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::loadBannerAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "loadBannerAdWithPlacementID:customDataJSONString:callback:", new object[]{placementID, customData != null ? customData : ""}, true);
|
||||
}
|
||||
|
||||
static public string checkAdStatus(string placementID) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::checkAdStatus(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "checkAdStatus:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public string getValidAdCaches(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATBannerAdWrapper::getValidAdCaches(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "getValidAdCaches:", new object[] { placementID });
|
||||
}
|
||||
|
||||
static public void hideBannerAd(string placementID) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::showBannerAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "hideBannerAdWithPlacementID:", new object[]{placementID}, false);
|
||||
}
|
||||
|
||||
static public void showBannerAd(string placementID) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::showBannerAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "showBannerAdWithPlacementID:", new object[]{placementID}, false);
|
||||
}
|
||||
|
||||
static public void showBannerAd(string placementID, string position)
|
||||
{
|
||||
Debug.Log("Unity: ATBannerAdWrapper::showBannerAd(" + placementID + "," + position + ")");
|
||||
Dictionary<string, object> rectDict = new Dictionary<string, object> { { "position", position } };
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "showBannerAdWithPlacementID:rect:extraJsonString:", new object[] { placementID, JsonMapper.ToJson(rectDict), null}, false);
|
||||
}
|
||||
|
||||
static public void showBannerAd(string placementID, string position, string mapJson)
|
||||
{
|
||||
Debug.Log("Unity: ATBannerAdWrapper::showBannerAd(" + placementID + "," + position + ")");
|
||||
Dictionary<string, object> rectDict = new Dictionary<string, object> { { "position", position } };
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "showBannerAdWithPlacementID:rect:extraJsonString:", new object[] { placementID, JsonMapper.ToJson(rectDict), mapJson}, false);
|
||||
}
|
||||
|
||||
static public void showBannerAd(string placementID, ATRect rect) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::showBannerAd(" + placementID + ")");
|
||||
Dictionary<string, object> rectDict = new Dictionary<string, object>{ {"x", rect.x}, {"y", rect.y}, {"width", rect.width}, {"height", rect.height}, {"uses_pixel", rect.usesPixel}};
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "showBannerAdWithPlacementID:rect:extraJsonString:", new object[]{placementID, JsonMapper.ToJson(rectDict), null}, false);
|
||||
}
|
||||
|
||||
static public void showBannerAd(string placementID, ATRect rect, string mapJson) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::showBannerAd(" + placementID + ")");
|
||||
Dictionary<string, object> rectDict = new Dictionary<string, object>{ {"x", rect.x}, {"y", rect.y}, {"width", rect.width}, {"height", rect.height}, {"uses_pixel", rect.usesPixel}};
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "showBannerAdWithPlacementID:rect:extraJsonString:", new object[]{placementID, JsonMapper.ToJson(rectDict), mapJson}, false);
|
||||
}
|
||||
|
||||
static public void cleanBannerAd(string placementID) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::cleanBannerAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "removeBannerAdWithPlacementID:", new object[]{placementID}, false);
|
||||
}
|
||||
|
||||
static public void clearCache() {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::clearCache()");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "clearCache", null);
|
||||
}
|
||||
|
||||
static public void setClientForPlacementID(string placementID, ATBannerAdClient client) {
|
||||
if (clients == null) clients = new Dictionary<string, ATBannerAdClient>();
|
||||
if (clients.ContainsKey(placementID)) clients.Remove(placementID);
|
||||
clients.Add(placementID, client);
|
||||
}
|
||||
|
||||
static private void OnBannerAdLoad(string placementID) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::OnBannerAdLoad()");
|
||||
if (clients[placementID] != null) clients[placementID].OnBannerAdLoad(placementID);
|
||||
}
|
||||
|
||||
static private void OnBannerAdLoadFail(string placementID, string code, string message) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::OnBannerAdLoadFail()");
|
||||
if (clients[placementID] != null) clients[placementID].OnBannerAdLoadFail(placementID, code, message);
|
||||
}
|
||||
|
||||
static private void OnBannerAdImpress(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::OnBannerAdImpress()");
|
||||
if (clients[placementID] != null) clients[placementID].OnBannerAdImpress(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnBannerAdClick(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::OnBannerAdClick()");
|
||||
if (clients[placementID] != null) clients[placementID].OnBannerAdClick(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnBannerAdAutoRefresh(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::OnBannerAdAutoRefresh()");
|
||||
if (clients[placementID] != null) clients[placementID].OnBannerAdAutoRefresh(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnBannerAdAutoRefreshFail(string placementID, string code, string message) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::OnBannerAdAutoRefreshFail()");
|
||||
if (clients[placementID] != null) clients[placementID].OnBannerAdAutoRefreshFail(placementID, code, message);
|
||||
}
|
||||
|
||||
static private void OnBannerAdCloseButtonTapped(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::onAdCloseButtonTapped()");
|
||||
if (clients[placementID] != null) clients[placementID].OnBannerAdCloseButtonTapped(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnBannerAdClose(string placementID) {
|
||||
Debug.Log("Unity: ATBannerAdWrapper::OnBannerAdClose()");
|
||||
if (clients[placementID] != null) clients[placementID].OnBannerAdClose(placementID);
|
||||
}
|
||||
|
||||
// ad source callback
|
||||
static public void StartLoadingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATBannerAdWrapper::StartLoadingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].startLoadingADSource(placementID, callbackJson);
|
||||
}
|
||||
static public void FinishLoadingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATBannerAdWrapper::FinishLoadingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].finishLoadingADSource(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void FailToLoadADSource(string placementID,string callbackJson, Dictionary<string, object> errorDict)
|
||||
{
|
||||
Debug.Log("Unity: ATBannerAdWrapper::FailToLoadADSource()");
|
||||
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].failToLoadADSource(placementID,callbackJson, (string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static public void StartBiddingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATBannerAdWrapper::StartBiddingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].startBiddingADSource(placementID, callbackJson);
|
||||
}
|
||||
static public void FinishBiddingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATBannerAdWrapper::FinishBiddingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].finishBiddingADSource(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void FailBiddingADSource(string placementID,string callbackJson, Dictionary<string, object> errorDict)
|
||||
{
|
||||
Debug.Log("Unity: ATBannerAdWrapper::FailBiddingADSource()");
|
||||
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].failBiddingADSource(placementID, callbackJson,(string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42e47e3e8cae64aa38bff4e3c6abf118
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,263 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using AOT;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
using AnyThinkAds.iOS;
|
||||
#pragma warning disable 0109
|
||||
public class ATInterstitialAdWrapper:ATAdWrapper {
|
||||
static private Dictionary<string, ATInterstitialAdClient> clients;
|
||||
static private string CMessaageReceiverClass = "ATInterstitialAdWrapper";
|
||||
|
||||
static public new void InvokeCallback(JsonData jsonData) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::InvokeCallback()");
|
||||
string extraJson = "";
|
||||
string callback = (string)jsonData["callback"];
|
||||
Dictionary<string, object> msgDict = JsonMapper.ToObject<Dictionary<string, object>>(jsonData["msg"].ToJson());
|
||||
JsonData msgJsonData = jsonData["msg"];
|
||||
IDictionary idic = (System.Collections.IDictionary)msgJsonData;
|
||||
|
||||
if (idic.Contains("extra")) {
|
||||
JsonData extraJsonDate = msgJsonData["extra"];
|
||||
if (extraJsonDate != null) {
|
||||
extraJson = msgJsonData["extra"].ToJson();
|
||||
}
|
||||
}
|
||||
|
||||
if (callback.Equals("OnInterstitialAdLoaded")) {
|
||||
OnInterstitialAdLoaded((string)msgDict["placement_id"]);
|
||||
} else if (callback.Equals("OnInterstitialAdLoadFailure")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
OnInterstitialAdLoadFailure((string)msgDict["placement_id"], errorDict);
|
||||
} else if (callback.Equals("OnInterstitialAdVideoPlayFailure")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
OnInterstitialAdVideoPlayFailure((string)msgDict["placement_id"], errorDict);
|
||||
} else if (callback.Equals("OnInterstitialAdVideoPlayStart")) {
|
||||
OnInterstitialAdVideoPlayStart((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnInterstitialAdVideoPlayEnd")) {
|
||||
OnInterstitialAdVideoPlayEnd((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnInterstitialAdShow")) {
|
||||
OnInterstitialAdShow((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnInterstitialAdClick")) {
|
||||
OnInterstitialAdClick((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnInterstitialAdClose")) {
|
||||
OnInterstitialAdClose((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnInterstitialAdFailedToShow")) {
|
||||
OnInterstitialAdFailedToShow((string)msgDict["placement_id"]);
|
||||
}else if (callback.Equals("startLoadingADSource")) {
|
||||
StartLoadingADSource((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("finishLoadingADSource")) {
|
||||
FinishLoadingADSource((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("failToLoadADSource")) {
|
||||
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
FailToLoadADSource((string)msgDict["placement_id"],extraJson, errorDict);
|
||||
|
||||
}else if (callback.Equals("startBiddingADSource")) {
|
||||
StartBiddingADSource((string)msgDict["placement_id"], extraJson);
|
||||
|
||||
}else if (callback.Equals("finishBiddingADSource")) {
|
||||
FinishBiddingADSource((string)msgDict["placement_id"], extraJson);
|
||||
|
||||
}else if (callback.Equals("failBiddingADSource")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
FailBiddingADSource((string)msgDict["placement_id"],extraJson, errorDict);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static public void setClientForPlacementID(string placementID, ATInterstitialAdClient client) {
|
||||
if (clients == null) clients = new Dictionary<string, ATInterstitialAdClient>();
|
||||
if (clients.ContainsKey(placementID)) clients.Remove(placementID);
|
||||
clients.Add(placementID, client);
|
||||
}
|
||||
|
||||
static public void loadInterstitialAd(string placementID, string customData) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::loadInterstitialAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "loadInterstitialAdWithPlacementID:customDataJSONString:callback:", new object[]{placementID, customData != null ? customData : ""}, true);
|
||||
}
|
||||
|
||||
static public bool hasInterstitialAdReady(string placementID) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::isInterstitialAdReady(" + placementID + ")");
|
||||
return ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "interstitialAdReadyForPlacementID:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public void showInterstitialAd(string placementID, string mapJson) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::showInterstitialAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "showInterstitialAdWithPlacementID:extraJsonString:", new object[]{placementID, mapJson});
|
||||
}
|
||||
|
||||
static public void clearCache(string placementID) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::clearCache()");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "clearCache", null);
|
||||
}
|
||||
|
||||
static public string checkAdStatus(string placementID) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::checkAdStatus(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "checkAdStatus:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public string getValidAdCaches(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::checkAdStatus(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "getValidAdCaches:", new object[] { placementID });
|
||||
}
|
||||
|
||||
static public void entryScenarioWithPlacementID(string placementID, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::entryScenarioWithPlacementID(" + placementID + scenarioID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "entryScenarioWithPlacementID:scenarioID:", new object[]{placementID, scenarioID});
|
||||
}
|
||||
|
||||
//Callbacks
|
||||
static private void OnInterstitialAdLoaded(string placementID) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::OnInterstitialAdLoaded()");
|
||||
if (clients[placementID] != null) clients[placementID].OnInterstitialAdLoaded(placementID);
|
||||
}
|
||||
|
||||
static private void OnInterstitialAdLoadFailure(string placementID, Dictionary<string, object> errorDict) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::OnInterstitialAdLoadFailure()");
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].OnInterstitialAdLoadFailure(placementID, (string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static private void OnInterstitialAdVideoPlayFailure(string placementID, Dictionary<string, object> errorDict) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::OnInterstitialAdVideoPlayFailure()");
|
||||
if (clients[placementID] != null) clients[placementID].OnInterstitialAdVideoPlayFailure(placementID, (string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static private void OnInterstitialAdVideoPlayStart(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::OnInterstitialAdPlayStart()");
|
||||
if (clients[placementID] != null) clients[placementID].OnInterstitialAdVideoPlayStart(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnInterstitialAdVideoPlayEnd(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::OnInterstitialAdVideoPlayEnd()");
|
||||
if (clients[placementID] != null) clients[placementID].OnInterstitialAdVideoPlayEnd(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnInterstitialAdShow(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::OnInterstitialAdShow()");
|
||||
if (clients[placementID] != null) clients[placementID].OnInterstitialAdShow(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnInterstitialAdFailedToShow(string placementID) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::OnInterstitialAdFailedToShow()");
|
||||
if (clients[placementID] != null) clients[placementID].OnInterstitialAdFailedToShow(placementID);
|
||||
}
|
||||
|
||||
static private void OnInterstitialAdClick(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::OnInterstitialAdClick()");
|
||||
if (clients[placementID] != null) clients[placementID].OnInterstitialAdClick(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnInterstitialAdClose(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::OnInterstitialAdClose()");
|
||||
if (clients[placementID] != null) clients[placementID].OnInterstitialAdClose(placementID, callbackJson);
|
||||
}
|
||||
// ad source callback
|
||||
static public void StartLoadingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::StartLoadingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].startLoadingADSource(placementID, callbackJson);
|
||||
}
|
||||
static public void FinishLoadingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::FinishLoadingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].finishLoadingADSource(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void FailToLoadADSource(string placementID,string callbackJson, Dictionary<string, object> errorDict)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::FailToLoadADSource()");
|
||||
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].failToLoadADSource(placementID,callbackJson,(string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static public void StartBiddingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::StartBiddingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].startBiddingADSource(placementID, callbackJson);
|
||||
}
|
||||
static public void FinishBiddingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::FinishBiddingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].finishBiddingADSource(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void FailBiddingADSource(string placementID, string callbackJson,Dictionary<string, object> errorDict)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::FailBiddingADSource()");
|
||||
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].failBiddingADSource(placementID,callbackJson,(string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
// Auto
|
||||
static public void addAutoLoadAdPlacementID(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::addAutoLoadAdPlacementID(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "addAutoLoadAdPlacementID:callback:", new object[]{placementID}, true);
|
||||
}
|
||||
|
||||
static public void removeAutoLoadAdPlacementID(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::removeAutoLoadAdPlacementID(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "removeAutoLoadAdPlacementID:", new object[]{placementID});
|
||||
}
|
||||
static public bool autoLoadInterstitialAdReadyForPlacementID(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::autoLoadInterstitialAdReadyForPlacementID(" + placementID + ")");
|
||||
|
||||
return ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "autoLoadInterstitialAdReadyForPlacementID:", new object[]{placementID});
|
||||
}
|
||||
static public string getAutoValidAdCaches(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::getAutoValidAdCaches");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "getAutoValidAdCaches:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public string checkAutoAdStatus(string placementID) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::checkAutoAdStatus(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "checkAutoAdStatus:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public void setAutoLocalExtra(string placementID, string customData)
|
||||
{
|
||||
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::setAutoLocalExtra(" + placementID + customData + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "setAutoLocalExtra:customDataJSONString:", new object[] {placementID, customData != null ? customData : ""});
|
||||
}
|
||||
|
||||
static public void entryAutoAdScenarioWithPlacementID(string placementID, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::entryAutoAdScenarioWithPlacementID(" + placementID + scenarioID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "entryAutoAdScenarioWithPlacementID:scenarioID:", new object[]{placementID, scenarioID});
|
||||
}
|
||||
|
||||
static public void showAutoInterstitialAd(string placementID, string mapJson) {
|
||||
Debug.Log("Unity: ATInterstitialAdWrapper::showAutoInterstitialAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "showAutoInterstitialAd:extraJsonString:", new object[]{placementID, mapJson});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7657f58beb3f24ea89bca929994062e3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,136 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
public class ATManager {
|
||||
private static bool SDKStarted;
|
||||
public static bool StartSDK(string appID, string appKey) {
|
||||
Debug.Log("Unity: ATManager::StartSDK(" + appID + "," + appKey + ")");
|
||||
if (!SDKStarted) {
|
||||
Debug.Log("Has not been started before, will starting SDK");
|
||||
SDKStarted = true;
|
||||
return ATUnityCBridge.SendMessageToC("ATUnityManager", "startSDKWithAppID:appKey:", new object[]{appID, appKey});
|
||||
} else {
|
||||
Debug.Log("SDK has been started already, ignore this call");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPurchaseFlag() {
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "setPurchaseFlag", null);
|
||||
}
|
||||
|
||||
public static void clearPurchaseFlag() {
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "clearPurchaseFlag", null);
|
||||
}
|
||||
|
||||
public static bool purchaseFlag() {
|
||||
return ATUnityCBridge.SendMessageToC("ATUnityManager", "clearPurchaseFlag", null);
|
||||
}
|
||||
|
||||
public static bool isEUTraffic() {
|
||||
return ATUnityCBridge.SendMessageToC("ATUnityManager", "inDataProtectionArea", null);
|
||||
}
|
||||
|
||||
public static void getUserLocation(Func<string, int> callback)
|
||||
{
|
||||
Debug.Log("Unity:ATManager::getUserLocation()");
|
||||
ATUnityCBridge.SendMessageToCWithCallBack("ATUnityManager", "getUserLocation:", new object[] { }, callback);
|
||||
}
|
||||
|
||||
public static void ShowGDPRAuthDialog() {
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "presentDataConsentDialog", null);
|
||||
}
|
||||
|
||||
public static int GetDataConsent() {
|
||||
return ATUnityCBridge.GetMessageFromC("ATUnityManager", "getDataConsent", null);
|
||||
}
|
||||
|
||||
public static void SetDataConsent(int consent) {
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "setDataConsent:", new object[]{consent});
|
||||
}
|
||||
|
||||
public static void SetNetworkGDPRInfo(int network, string mapJson) {
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "setDataConsent:network:", new object[]{mapJson, network});
|
||||
}
|
||||
|
||||
public static void setChannel(string channel)
|
||||
{
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "setChannel:", new object[] {channel});
|
||||
}
|
||||
|
||||
public static void setSubChannel(string subchannel)
|
||||
{
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "setSubChannel:", new object[] {subchannel});
|
||||
}
|
||||
|
||||
public static void setCustomMap(string jsonMap)
|
||||
{
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "setCustomData:", new object[] { jsonMap });
|
||||
}
|
||||
|
||||
public static void setCustomDataForPlacementID(string customData, string placementID)
|
||||
{
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "setCustomData:forPlacementID:", new object[] {customData, placementID});
|
||||
}
|
||||
|
||||
public static void setLogDebug(bool isDebug)
|
||||
{
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "setDebugLog:", new object[] { isDebug ? "true" : "false" });
|
||||
}
|
||||
|
||||
public static void deniedUploadDeviceInfo(string deniedInfo)
|
||||
{
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "deniedUploadDeviceInfo:", new object[] {deniedInfo});
|
||||
}
|
||||
|
||||
public static void setExcludeBundleIdArray(string bundleIds)
|
||||
{
|
||||
Debug.Log("Unity:ATManager::setExcludeBundleIdArray()");
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "setExcludeBundleIdArray:", new object[] {bundleIds});
|
||||
}
|
||||
|
||||
public static void setExcludeAdSourceIdArrayForPlacementID(string placementID, string adSourceIds)
|
||||
{
|
||||
Debug.Log("Unity:ATManager::setExcludeAdSourceIdArrayForPlacementID()");
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "setExludePlacementid:unitIDArray:", new object[] {placementID, adSourceIds});
|
||||
}
|
||||
|
||||
public static void setSDKArea(int area)
|
||||
{
|
||||
Debug.Log("Unity:ATManager::setSDKArea()");
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "setSDKArea:", new object[] {area});
|
||||
}
|
||||
|
||||
public static void getArea(Func<string, int> callback)
|
||||
{
|
||||
Debug.Log("Unity:ATManager::getArea()");
|
||||
ATUnityCBridge.SendMessageToCWithCallBack("ATUnityManager", "getArea:", new object[] { }, callback);
|
||||
}
|
||||
|
||||
public static void setWXStatus(bool install)
|
||||
{
|
||||
Debug.Log("Unity:ATManager::setWXStatus()");
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "setWXStatus:", new object[] {install});
|
||||
}
|
||||
|
||||
public static void setLocation(double longitude, double latitude)
|
||||
{
|
||||
Debug.Log("Unity:ATManager::setLocation()");
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "setLocationLongitude:dimension:", new object[] {longitude, latitude});
|
||||
}
|
||||
|
||||
public static void showDebuggerUI()
|
||||
{
|
||||
Debug.Log("Unity:ATManager::showDebuggerUI()");
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "showDebuggerUI", null);
|
||||
}
|
||||
|
||||
public static void showGDPRConsentDialog(Func<string, int> callback)
|
||||
{
|
||||
Debug.Log("Unity:ATManager::showGDPRConsentDialog()");
|
||||
ATUnityCBridge.SendMessageToCWithCallBack("ATUnityManager", "showGDPRConsentDialog:", new object[] { }, callback);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2004f8da35b374bebbed4dc94a4c9626
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,200 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using AOT;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
using AnyThinkAds.iOS;
|
||||
#pragma warning disable 0109
|
||||
public class ATNativeAdWrapper:ATAdWrapper {
|
||||
static private Dictionary<string, ATNativeAdClient> clients;
|
||||
static private string CMessageReceiverClass = "ATNativeAdWrapper";
|
||||
|
||||
static public new void InvokeCallback(JsonData jsonData) {
|
||||
Debug.Log("Unity: ATNativeAdWrapper::InvokeCallback()");
|
||||
string extraJson = "";
|
||||
string callback = (string)jsonData["callback"];
|
||||
Dictionary<string, object> msgDict = JsonMapper.ToObject<Dictionary<string, object>>(jsonData["msg"].ToJson());
|
||||
JsonData msgJsonData = jsonData["msg"];
|
||||
IDictionary idic = (System.Collections.IDictionary)msgJsonData;
|
||||
|
||||
if (idic.Contains("extra")) {
|
||||
JsonData extraJsonDate = msgJsonData["extra"];
|
||||
if (extraJsonDate != null) {
|
||||
extraJson = msgJsonData["extra"].ToJson();
|
||||
}
|
||||
}
|
||||
|
||||
if (callback.Equals("OnNativeAdLoaded")) {
|
||||
OnNativeAdLoaded((string)msgDict["placement_id"]);
|
||||
} else if (callback.Equals("OnNativeAdLoadingFailure")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
OnNativeAdLoadingFailure((string)msgDict["placement_id"], errorDict);
|
||||
} else if (callback.Equals("OnNaitveAdShow")) {
|
||||
OnNaitveAdShow((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnNativeAdClick")) {
|
||||
OnNativeAdClick((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnNativeAdVideoStart")) {
|
||||
OnNativeAdVideoStart((string)msgDict["placement_id"]);
|
||||
} else if (callback.Equals("OnNativeAdVideoEnd")) {
|
||||
OnNativeAdVideoEnd((string)msgDict["placement_id"]);
|
||||
} else if (callback.Equals("OnNativeAdCloseButtonClick")) {
|
||||
OnNativeAdCloseButtonClick((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("startLoadingADSource")) {
|
||||
StartLoadingADSource((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("finishLoadingADSource")) {
|
||||
FinishLoadingADSource((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("failToLoadADSource")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
FailToLoadADSource((string)msgDict["placement_id"],extraJson, errorDict);
|
||||
}else if (callback.Equals("startBiddingADSource")) {
|
||||
StartBiddingADSource((string)msgDict["placement_id"], extraJson);
|
||||
|
||||
}else if (callback.Equals("finishBiddingADSource")) {
|
||||
FinishBiddingADSource((string)msgDict["placement_id"], extraJson);
|
||||
|
||||
}else if (callback.Equals("failBiddingADSource")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
FailBiddingADSource((string)msgDict["placement_id"],extraJson, errorDict);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Public method(s)
|
||||
static public void setClientForPlacementID(string placementID, ATNativeAdClient client) {
|
||||
if (clients == null) clients = new Dictionary<string, ATNativeAdClient>();
|
||||
if (clients.ContainsKey(placementID)) clients.Remove(placementID);
|
||||
clients.Add(placementID, client);
|
||||
}
|
||||
|
||||
static public void loadNativeAd(string placementID, string customData) {
|
||||
Debug.Log("Unity: ATNativeAdWrapper::loadNativeAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "loadNativeAdWithPlacementID:customDataJSONString:callback:", new object[]{placementID, customData != null ? customData : ""}, true);
|
||||
}
|
||||
|
||||
static public bool isNativeAdReady(string placementID) {
|
||||
Debug.Log("Unity: ATNativeAdWrapper::isNativeAdReady(" + placementID + ")");
|
||||
return ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "isNativeAdReadyForPlacementID:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public string checkAdStatus(string placementID) {
|
||||
Debug.Log("Unity: ATNativeAdWrapper::checkAdStatus(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessageReceiverClass, "checkAdStatus:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public string getValidAdCaches(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdWrapper::getValidAdCaches(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessageReceiverClass, "getValidAdCaches:", new object[] { placementID });
|
||||
}
|
||||
|
||||
static public void entryScenarioWithPlacementID(string placementID, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdWrapper::entryScenarioWithPlacementID(" + placementID + scenarioID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "entryScenarioWithPlacementID:scenarioID:", new object[]{placementID, scenarioID});
|
||||
}
|
||||
|
||||
static public void showNativeAd(string placementID, string metrics) {
|
||||
Debug.Log("Unity: ATNativeAdWrapper::showNativeAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "showNativeAdWithPlacementID:metricsJSONString:extraJsonString:", new object[]{placementID, metrics, null});
|
||||
}
|
||||
|
||||
static public void showNativeAd(string placementID, string metrics, string mapJson) {
|
||||
Debug.Log("Unity: ATNativeAdWrapper::showNativeAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "showNativeAdWithPlacementID:metricsJSONString:extraJsonString:", new object[]{placementID, metrics, mapJson});
|
||||
}
|
||||
|
||||
static public void removeNativeAdView(string placementID) {
|
||||
Debug.Log("Unity: ATNativeAdWrapper::removeNativeAdView(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "removeNativeAdViewWithPlacementID:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public void clearCache() {
|
||||
Debug.Log("Unity: ATNativeAdWrapper::clearCache()");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "clearCache", null);
|
||||
}
|
||||
|
||||
//Callbacks
|
||||
static private void OnNativeAdLoaded(string placementID) {
|
||||
Debug.Log("Unity: ATNativeAdWrapper::OnNativeAdLoaded(" + placementID + ")");
|
||||
if (clients[placementID] != null) clients[placementID].onNativeAdLoaded(placementID);
|
||||
}
|
||||
|
||||
static private void OnNativeAdLoadingFailure(string placementID, Dictionary<string, object> errorDict) {
|
||||
Debug.Log("Unity: ATNativeAdWrapper::OnNativeAdLoadingFailure()");
|
||||
if (clients[placementID] != null) clients[placementID].onNativeAdLoadFail(placementID, (string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static private void OnNaitveAdShow(string placementID, string callbackJson) {
|
||||
if (clients[placementID] != null) clients[placementID].onAdImpressed(placementID, callbackJson);
|
||||
Debug.Log("Unity: ATNativeAdWrapper::OnNaitveAdShow(" + placementID + ")");
|
||||
}
|
||||
|
||||
static private void OnNativeAdClick(string placementID, string callbackJson) {
|
||||
if (clients[placementID] != null) clients[placementID].onAdClicked(placementID, callbackJson);
|
||||
Debug.Log("Unity: ATNativeAdWrapper::OnNativeAdClick(" + placementID + ")");
|
||||
}
|
||||
|
||||
static private void OnNativeAdVideoStart(string placementID) {
|
||||
if (clients[placementID] != null) clients[placementID].onAdVideoStart(placementID);
|
||||
Debug.Log("Unity: ATNativeAdWrapper::OnNativeAdVideoStart(" + placementID + ")");
|
||||
}
|
||||
|
||||
static private void OnNativeAdVideoEnd(string placementID) {
|
||||
if (clients[placementID] != null) clients[placementID].onAdVideoEnd(placementID);
|
||||
Debug.Log("Unity: ATNativeAdWrapper::OnNativeAdVideoEnd(" + placementID + ")");
|
||||
}
|
||||
|
||||
static private void OnNativeAdCloseButtonClick(string placementID, string callbackJson)
|
||||
{
|
||||
if (clients[placementID] != null) clients[placementID].onAdCloseButtonClicked(placementID, callbackJson);
|
||||
Debug.Log("Unity: ATNativeAdWrapper::OnNativeAdCloseButtonClick(" + placementID + ")");
|
||||
}
|
||||
// ad source callback
|
||||
static public void StartLoadingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdWrapper::StartLoadingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].startLoadingADSource(placementID, callbackJson);
|
||||
}
|
||||
static public void FinishLoadingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdWrapper::FinishLoadingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].finishLoadingADSource(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void FailToLoadADSource(string placementID,string callbackJson, Dictionary<string, object> errorDict)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdWrapper::FailToLoadADSource()");
|
||||
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].failToLoadADSource(placementID,callbackJson, (string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static public void StartBiddingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdWrapper::StartBiddingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].startBiddingADSource(placementID, callbackJson);
|
||||
}
|
||||
static public void FinishBiddingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdWrapper::FinishBiddingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].finishBiddingADSource(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void FailBiddingADSource(string placementID,string callbackJson, Dictionary<string, object> errorDict)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdWrapper::FailBiddingADSource()");
|
||||
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].failBiddingADSource(placementID, callbackJson,(string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e618652cb8c1948ae800e140df614aa5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,131 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using AOT;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
using AnyThinkAds.iOS;
|
||||
using AnyThinkAds.Api;
|
||||
#pragma warning disable 0109
|
||||
public class ATNativeBannerAdWrapper : ATAdWrapper {
|
||||
static private Dictionary<string, ATNativeBannerAdClient> clients;
|
||||
static private string CMessageReceiverClass = "ATNativeBannerAdWrapper";
|
||||
|
||||
static public new void InvokeCallback(JsonData jsonData) {
|
||||
Debug.Log("Unity: ATNativeBannerAdWrapper::InvokeCallback()");
|
||||
string extraJson = "";
|
||||
string callback = (string)jsonData["callback"];
|
||||
Dictionary<string, object> msgDict = JsonMapper.ToObject<Dictionary<string, object>>(jsonData["msg"].ToJson());
|
||||
JsonData msgJsonData = jsonData["msg"];
|
||||
IDictionary idic = (System.Collections.IDictionary)msgJsonData;
|
||||
|
||||
if (idic.Contains("extra")) {
|
||||
JsonData extraJsonDate = msgJsonData["extra"];
|
||||
if (extraJsonDate != null) {
|
||||
extraJson = msgJsonData["extra"].ToJson();
|
||||
}
|
||||
}
|
||||
|
||||
if (callback.Equals("OnNativeBannerAdLoaded")) {
|
||||
OnNativeBannerAdLoaded((string)msgDict["placement_id"]);
|
||||
} else if (callback.Equals("OnNativeBannerAdLoadingFailure")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
OnNativeBannerAdLoadingFailure((string)msgDict["placement_id"], errorDict);
|
||||
} else if (callback.Equals("OnNaitveBannerAdShow")) {
|
||||
OnNaitveBannerAdShow((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnNativeBannerAdClick")) {
|
||||
OnNativeBannerAdClick((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnNativeBannerAdAutorefresh")) {
|
||||
OnNativeBannerAdAutorefresh((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnNativeBannerAdAutorefreshFailed")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
OnNativeBannerAdAutorefreshFailed((string)msgDict["placement_id"], errorDict);
|
||||
} else if (callback.Equals("OnNativeBannerAdCloseButtonClicked")) {
|
||||
OnNativeBannerAdCloseButtonClicked((string)msgDict["placement_id"]);
|
||||
} else if (callback.Equals("PauseAudio")) {
|
||||
Debug.Log("c# : callback, PauseAudio");
|
||||
PauseAudio();
|
||||
} else if (callback.Equals("ResumeAudio")) {
|
||||
Debug.Log("c# : callback, ResumeAudio");
|
||||
ResumeAudio();
|
||||
}
|
||||
}
|
||||
|
||||
static public void PauseAudio() {
|
||||
Debug.Log("ATNativeBannerAdWrapper::PauseAudio()");
|
||||
}
|
||||
|
||||
static public void ResumeAudio() {
|
||||
Debug.Log("ATNativeBannerAdWrapper::ResumeAudio()");
|
||||
}
|
||||
|
||||
static public void setClientForPlacementID(string placementID, ATNativeBannerAdClient client) {
|
||||
Debug.Log("ATNativeBannerAdWrapper::setClientForPlacementID()");
|
||||
if (clients == null) clients = new Dictionary<string, ATNativeBannerAdClient>();
|
||||
if (clients.ContainsKey(placementID)) clients.Remove(placementID);
|
||||
clients.Add(placementID, client);
|
||||
}
|
||||
|
||||
static public void loadAd(string placementID, string customData) {
|
||||
Debug.Log("ATNativeBannerAdWrapper::loadAd()");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "loadNativeBannerAdWithPlacementID:customDataJSONString:callback:", new object[]{placementID, customData != null ? customData : ""}, true);
|
||||
}
|
||||
|
||||
static public bool adReady(string placementID) {
|
||||
Debug.Log("ATNativeBannerAdWrapper::adReady()");
|
||||
return ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "isNativeBannerAdReadyForPlacementID:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public void showAd(string placementID, ATRect rect, Dictionary<string, string> pairs) {
|
||||
Debug.Log("ATNativeBannerAdWrapper::showAd()");
|
||||
Dictionary<string, object> rectDict = new Dictionary<string, object>{ {"x", rect.x}, {"y", rect.y}, {"width", rect.width}, {"height", rect.height} };
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "showNativeBannerAdWithPlacementID:rect:extra:", new object[]{placementID, JsonMapper.ToJson(rectDict), JsonMapper.ToJson(pairs != null ? pairs : new Dictionary<string, string>())}, false);
|
||||
}
|
||||
|
||||
static public void removeAd(string placementID) {
|
||||
Debug.Log("ATNativeBannerAdWrapper::removeAd()");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "removeNativeBannerAdWithPlacementID:", new object[]{placementID}, false);
|
||||
}
|
||||
|
||||
//Callbacks
|
||||
static private void OnNativeBannerAdLoaded(string placementID) {
|
||||
Debug.Log("Unity: ATNativeBannerAdWrapper::OnNativeBannerAdLoaded(" + placementID + ")");
|
||||
if (clients[placementID] != null) clients[placementID].onAdLoaded(placementID);
|
||||
}
|
||||
|
||||
static private void OnNativeBannerAdLoadingFailure(string placementID, Dictionary<string, object> errorDict) {
|
||||
Debug.Log("Unity: ATNativeBannerAdWrapper::OnNativeBannerAdLoadingFailure(" + placementID + ")");
|
||||
if (clients[placementID] != null) clients[placementID].onAdLoadFail(placementID, (string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static private void OnNaitveBannerAdShow(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATNativeBannerAdWrapper::OnNaitveBannerAdShow(" + placementID + ")");
|
||||
if (clients[placementID] != null) clients[placementID].onAdImpressed(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnNativeBannerAdClick(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATNativeBannerAdWrapper::OnNativeBannerAdClick(" + placementID + ")");
|
||||
if (clients[placementID] != null) clients[placementID].onAdClicked(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnNativeBannerAdAutorefresh(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATNativeBannerAdWrapper::OnNativeBannerAdAutorefresh(" + placementID + ")");
|
||||
if (clients[placementID] != null) clients[placementID].onAdAutoRefresh(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnNativeBannerAdAutorefreshFailed(string placementID, Dictionary<string, object> errorDict) {
|
||||
Debug.Log("Unity: ATNativeBannerAdWrapper::OnNativeBannerAdAutorefreshFailed(" + placementID + ")");
|
||||
if (clients[placementID] != null) clients[placementID].onAdAutoRefreshFailure(placementID, (string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static private void OnNativeBannerAdCloseButtonClicked(string placementID) {
|
||||
Debug.Log("Unity: ATNativeBannerAdWrapper::OnNativeBannerAdCloseButtonClicked(" + placementID + ")");
|
||||
if (clients[placementID] != null) clients[placementID].onAdCloseButtonClicked(placementID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 736d70464c760423bb70a639660b2c2d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,313 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using AOT;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
using AnyThinkAds.iOS;
|
||||
#pragma warning disable 0109
|
||||
public class ATRewardedVideoWrapper:ATAdWrapper {
|
||||
static private Dictionary<string, ATRewardedVideoAdClient> clients;
|
||||
static private string CMessageReceiverClass = "ATRewardedVideoWrapper";
|
||||
|
||||
static public new void InvokeCallback(JsonData jsonData) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::InvokeCallback()");
|
||||
string extraJson = "";
|
||||
string callback = (string)jsonData["callback"];
|
||||
Dictionary<string, object> msgDict = JsonMapper.ToObject<Dictionary<string, object>>(jsonData["msg"].ToJson());
|
||||
JsonData msgJsonData = jsonData["msg"];
|
||||
IDictionary idic = (System.Collections.IDictionary)msgJsonData;
|
||||
|
||||
if (idic.Contains("extra")) {
|
||||
JsonData extraJsonDate = msgJsonData["extra"];
|
||||
if (extraJsonDate != null) {
|
||||
extraJson = msgJsonData["extra"].ToJson();
|
||||
}
|
||||
}
|
||||
|
||||
if (callback.Equals("OnRewardedVideoLoaded")) {
|
||||
OnRewardedVideoLoaded((string)msgDict["placement_id"]);
|
||||
} else if (callback.Equals("OnRewardedVideoLoadFailure")) {
|
||||
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
OnRewardedVideoLoadFailure((string)msgDict["placement_id"], errorDict);
|
||||
|
||||
} else if (callback.Equals("OnRewardedVideoPlayFailure")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
OnRewardedVideoPlayFailure((string)msgDict["placement_id"], errorDict);
|
||||
} else if (callback.Equals("OnRewardedVideoPlayStart")) {
|
||||
OnRewardedVideoPlayStart((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnRewardedVideoPlayEnd")) {
|
||||
OnRewardedVideoPlayEnd((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnRewardedVideoClick")) {
|
||||
OnRewardedVideoClick((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnRewardedVideoClose")) {
|
||||
OnRewardedVideoClose((string)msgDict["placement_id"], (bool)msgDict["rewarded"], extraJson);
|
||||
} else if (callback.Equals("OnRewardedVideoReward")) {
|
||||
OnRewardedVideoReward((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnRewardedVideoAdAgainPlayStart")) {
|
||||
OnRewardedVideoAdAgainPlayStart((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnRewardedVideoAdAgainPlayEnd")) {
|
||||
OnRewardedVideoAdAgainPlayEnd((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnRewardedVideoAdAgainPlayFailed")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
OnRewardedVideoAdAgainPlayFailed((string)msgDict["placement_id"], errorDict);
|
||||
} else if (callback.Equals("OnRewardedVideoAdAgainPlayClicked")) {
|
||||
OnRewardedVideoAdAgainPlayClicked((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("OnAgainReward")) {
|
||||
OnAgainReward((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("startLoadingADSource")) {
|
||||
StartLoadingADSource((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("finishLoadingADSource")) {
|
||||
FinishLoadingADSource((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("failToLoadADSource")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
|
||||
FailToLoadADSource((string)msgDict["placement_id"],extraJson,errorDict);
|
||||
}else if (callback.Equals("startBiddingADSource")) {
|
||||
StartBiddingADSource((string)msgDict["placement_id"], extraJson);
|
||||
|
||||
}else if (callback.Equals("finishBiddingADSource")) {
|
||||
FinishBiddingADSource((string)msgDict["placement_id"], extraJson);
|
||||
|
||||
}else if (callback.Equals("failBiddingADSource")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
FailBiddingADSource((string)msgDict["placement_id"],extraJson, errorDict);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Public method(s)
|
||||
static public void setClientForPlacementID(string placementID, ATRewardedVideoAdClient client) {
|
||||
if (clients == null) clients = new Dictionary<string, ATRewardedVideoAdClient>();
|
||||
if (clients.ContainsKey(placementID)) clients.Remove(placementID);
|
||||
clients.Add(placementID, client);
|
||||
}
|
||||
|
||||
static public void setExtra(Dictionary<string, object> extra) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::setExtra()");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "setExtra:", new object[]{extra});
|
||||
}
|
||||
|
||||
static public void loadRewardedVideo(string placementID, string customData) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::loadRewardedVideo(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "loadRewardedVideoWithPlacementID:customDataJSONString:callback:", new object[]{placementID, customData != null ? customData : ""}, true);
|
||||
}
|
||||
|
||||
static public bool isRewardedVideoReady(string placementID) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::isRewardedVideoReady(" + placementID + ")");
|
||||
return ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "rewardedVideoReadyForPlacementID:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public void showRewardedVideo(string placementID, string mapJson) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::showRewardedVideo(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "showRewardedVideoWithPlacementID:extraJsonString:", new object[]{placementID, mapJson});
|
||||
}
|
||||
|
||||
static public void clearCache() {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::clearCache()");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "clearCache", null);
|
||||
}
|
||||
|
||||
static public string checkAdStatus(string placementID) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::checkAdStatus(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessageReceiverClass, "checkAdStatus:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public string getValidAdCaches(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::getValidAdCaches(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessageReceiverClass, "getValidAdCaches:", new object[] { placementID });
|
||||
}
|
||||
|
||||
static public void entryScenarioWithPlacementID(string placementID, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::entryScenarioWithPlacementID(" + placementID + scenarioID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "entryScenarioWithPlacementID:scenarioID:", new object[]{placementID, scenarioID});
|
||||
}
|
||||
|
||||
//Callbacks
|
||||
static public void OnRewardedVideoLoaded(string placementID) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoLoaded()");
|
||||
if (clients[placementID] != null) clients[placementID].onRewardedVideoAdLoaded(placementID);
|
||||
}
|
||||
|
||||
static public void OnRewardedVideoLoadFailure(string placementID, Dictionary<string, object> errorDict) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoLoadFailure()");
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].onRewardedVideoAdFailed(placementID, (string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static public void OnRewardedVideoPlayFailure(string placementID, Dictionary<string, object> errorDict) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoPlayFailure()");
|
||||
if (clients[placementID] != null) clients[placementID].onRewardedVideoAdPlayFailed(placementID, (string)errorDict["code"], (string)errorDict["message"]);
|
||||
|
||||
}
|
||||
|
||||
static public void OnRewardedVideoPlayStart(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoPlayStart()");
|
||||
if (clients[placementID] != null) clients[placementID].onRewardedVideoAdPlayStart(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void OnRewardedVideoPlayEnd(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoPlayEnd()");
|
||||
if (clients[placementID] != null) clients[placementID].onRewardedVideoAdPlayEnd(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void OnRewardedVideoClick(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoClick()");
|
||||
if (clients[placementID] != null) clients[placementID].onRewardedVideoAdPlayClicked(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void OnRewardedVideoClose(string placementID, bool rewarded, string callbackJson) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoClose()");
|
||||
if (clients[placementID] != null) clients[placementID].onRewardedVideoAdClosed(placementID, rewarded, callbackJson);
|
||||
}
|
||||
static public void OnRewardedVideoReward(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoReward()");
|
||||
if (clients[placementID] != null) clients[placementID].onRewardedVideoReward(placementID, callbackJson);
|
||||
}
|
||||
|
||||
//------again callback
|
||||
static public void OnRewardedVideoAdAgainPlayStart(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::onRewardedVideoAdAgainPlayStart()");
|
||||
if (clients[placementID] != null) clients[placementID].onRewardedVideoAdAgainPlayStart(placementID, callbackJson);
|
||||
}
|
||||
|
||||
|
||||
static public void OnRewardedVideoAdAgainPlayEnd(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::onRewardedVideoAdAgainPlayEnd()");
|
||||
if (clients[placementID] != null) clients[placementID].onRewardedVideoAdAgainPlayEnd(placementID, callbackJson);
|
||||
}
|
||||
|
||||
|
||||
static public void OnRewardedVideoAdAgainPlayFailed(string placementID, Dictionary<string, object> errorDict)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::onRewardedVideoAdAgainPlayFailed()");
|
||||
if (clients[placementID] != null) clients[placementID].onRewardedVideoAdAgainPlayFailed(placementID, (string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
|
||||
static public void OnRewardedVideoAdAgainPlayClicked(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::onRewardedVideoAdAgainPlayClicked()");
|
||||
if (clients[placementID] != null) clients[placementID].onRewardedVideoAdAgainPlayClicked(placementID, callbackJson);
|
||||
}
|
||||
|
||||
|
||||
static public void OnAgainReward(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::onAgainReward()");
|
||||
if (clients[placementID] != null) clients[placementID].onAgainReward(placementID, callbackJson);
|
||||
}
|
||||
|
||||
// Auto
|
||||
static public void addAutoLoadAdPlacementID(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::addAutoLoadAdPlacementID(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "addAutoLoadAdPlacementID:callback:", new object[]{placementID}, true);
|
||||
}
|
||||
|
||||
static public void removeAutoLoadAdPlacementID(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::removeAutoLoadAdPlacementID(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "removeAutoLoadAdPlacementID:", new object[]{placementID});
|
||||
}
|
||||
static public bool autoLoadRewardedVideoReadyForPlacementID(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::autoLoadRewardedVideoReadyForPlacementID(" + placementID + ")");
|
||||
return ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "autoLoadRewardedVideoReadyForPlacementID:", new object[]{placementID});
|
||||
}
|
||||
static public string getAutoValidAdCaches(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::getAutoValidAdCaches");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessageReceiverClass, "getAutoValidAdCaches:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public string checkAutoAdStatus(string placementID) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::checkAutoAdStatus(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessageReceiverClass, "checkAutoAdStatus:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public void setAutoLocalExtra(string placementID, string customData)
|
||||
{
|
||||
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::setAutoLocalExtra(" + placementID + customData + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "setAutoLocalExtra:customDataJSONString:", new object[] {placementID, customData != null ? customData : ""});
|
||||
}
|
||||
|
||||
static public void entryAutoAdScenarioWithPlacementID(string placementID, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::entryAutoAdScenarioWithPlacementID(" + placementID + scenarioID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "entryAutoAdScenarioWithPlacementID:scenarioID:", new object[]{placementID, scenarioID});
|
||||
}
|
||||
|
||||
static public void showAutoRewardedVideo(string placementID, string mapJson) {
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::showAutoRewardedVideo(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "showAutoRewardedVideoWithPlacementID:extraJsonString:", new object[]{placementID, mapJson});
|
||||
}
|
||||
|
||||
// ad source callback
|
||||
static public void StartLoadingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::StartLoadingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].startLoadingADSource(placementID, callbackJson);
|
||||
}
|
||||
static public void FinishLoadingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::FinishLoadingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].finishLoadingADSource(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void FailToLoadADSource(string placementID, string callbackJson, Dictionary<string, object> errorDict)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::FailToLoadADSource()");
|
||||
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].failToLoadADSource(placementID, callbackJson,(string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static public void StartBiddingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::StartBiddingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].startBiddingADSource(placementID, callbackJson);
|
||||
}
|
||||
static public void FinishBiddingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::FinishBiddingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].finishBiddingADSource(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void FailBiddingADSource(string placementID, string callbackJson,Dictionary<string, object> errorDict)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoWrapper::FailBiddingADSource()");
|
||||
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].failBiddingADSource(placementID,callbackJson,(string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fd828a1082d34e828c247d3c1f1e8d1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,263 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using AOT;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
using AnyThinkAds.iOS;
|
||||
#pragma warning disable 0109
|
||||
public class ATSplashAdWrapper:ATAdWrapper {
|
||||
static private Dictionary<string, ATSplashAdClient> clients;
|
||||
static private string CMessaageReceiverClass = "ATSplashAdWrapper";
|
||||
|
||||
static public new void InvokeCallback(JsonData jsonData) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::InvokeCallback()");
|
||||
string extraJson = "";
|
||||
string callback = (string)jsonData["callback"];
|
||||
Dictionary<string, object> msgDict = JsonMapper.ToObject<Dictionary<string, object>>(jsonData["msg"].ToJson());
|
||||
JsonData msgJsonData = jsonData["msg"];
|
||||
IDictionary idic = (System.Collections.IDictionary)msgJsonData;
|
||||
|
||||
if (idic.Contains("extra")) {
|
||||
JsonData extraJsonDate = msgJsonData["extra"];
|
||||
if (extraJsonDate != null) {
|
||||
extraJson = msgJsonData["extra"].ToJson();
|
||||
}
|
||||
}
|
||||
|
||||
if (callback.Equals("OnSplashAdLoaded")) {
|
||||
OnSplashAdLoaded((string)msgDict["placement_id"]);
|
||||
} else if (callback.Equals("OnSplashAdLoadFailure")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
OnSplashAdLoadFailure((string)msgDict["placement_id"], errorDict);
|
||||
} else if (callback.Equals("OnSplashAdVideoPlayFailure")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
OnSplashAdVideoPlayFailure((string)msgDict["placement_id"], errorDict);
|
||||
} else if (callback.Equals("OnSplashAdVideoPlayStart")) {
|
||||
OnSplashAdVideoPlayStart((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnSplashAdVideoPlayEnd")) {
|
||||
OnSplashAdVideoPlayEnd((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnSplashAdShow")) {
|
||||
OnSplashAdShow((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnSplashAdClick")) {
|
||||
OnSplashAdClick((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnSplashAdClose")) {
|
||||
OnSplashAdClose((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnSplashAdFailedToShow")) {
|
||||
OnSplashAdFailedToShow((string)msgDict["placement_id"]);
|
||||
}else if (callback.Equals("startLoadingADSource")) {
|
||||
StartLoadingADSource((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("finishLoadingADSource")) {
|
||||
FinishLoadingADSource((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("failToLoadADSource")) {
|
||||
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
FailToLoadADSource((string)msgDict["placement_id"],extraJson, errorDict);
|
||||
|
||||
}else if (callback.Equals("startBiddingADSource")) {
|
||||
StartBiddingADSource((string)msgDict["placement_id"], extraJson);
|
||||
|
||||
}else if (callback.Equals("finishBiddingADSource")) {
|
||||
FinishBiddingADSource((string)msgDict["placement_id"], extraJson);
|
||||
|
||||
}else if (callback.Equals("failBiddingADSource")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
FailBiddingADSource((string)msgDict["placement_id"],extraJson, errorDict);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static public void setClientForPlacementID(string placementID, ATSplashAdClient client) {
|
||||
if (clients == null) clients = new Dictionary<string, ATSplashAdClient>();
|
||||
if (clients.ContainsKey(placementID)) clients.Remove(placementID);
|
||||
clients.Add(placementID, client);
|
||||
}
|
||||
|
||||
static public void loadSplashAd(string placementID, string customData) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::loadSplashAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "loadSplashAdWithPlacementID:customDataJSONString:callback:", new object[]{placementID, customData != null ? customData : ""}, true);
|
||||
}
|
||||
|
||||
static public bool hasSplashAdReady(string placementID) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::isSplashAdReady(" + placementID + ")");
|
||||
return ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "splashAdReadyForPlacementID:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public void showSplashAd(string placementID, string mapJson) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::showSplashAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "showSplashAdWithPlacementID:extraJsonString:", new object[]{placementID, mapJson});
|
||||
}
|
||||
|
||||
static public void clearCache(string placementID) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::clearCache()");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "clearCache", null);
|
||||
}
|
||||
|
||||
static public string checkAdStatus(string placementID) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::checkAdStatus(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "checkAdStatus:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public string getValidAdCaches(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::checkAdStatus(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "getValidAdCaches:", new object[] { placementID });
|
||||
}
|
||||
|
||||
static public void entryScenarioWithPlacementID(string placementID, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::entryScenarioWithPlacementID(" + placementID + scenarioID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "entryScenarioWithPlacementID:scenarioID:", new object[]{placementID, scenarioID});
|
||||
}
|
||||
|
||||
//Callbacks
|
||||
static private void OnSplashAdLoaded(string placementID) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdLoaded()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdLoaded(placementID);
|
||||
}
|
||||
|
||||
static private void OnSplashAdLoadFailure(string placementID, Dictionary<string, object> errorDict) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdLoadFailure()");
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdLoadFailure(placementID, (string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static private void OnSplashAdVideoPlayFailure(string placementID, Dictionary<string, object> errorDict) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdVideoPlayFailure()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdVideoPlayFailure(placementID, (string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static private void OnSplashAdVideoPlayStart(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdPlayStart()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdVideoPlayStart(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnSplashAdVideoPlayEnd(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdVideoPlayEnd()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdVideoPlayEnd(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnSplashAdShow(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdShow()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdShow(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnSplashAdFailedToShow(string placementID) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdFailedToShow()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdFailedToShow(placementID);
|
||||
}
|
||||
|
||||
static private void OnSplashAdClick(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdClick()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdClick(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnSplashAdClose(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdClose()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdClose(placementID, callbackJson);
|
||||
}
|
||||
// ad source callback
|
||||
static public void StartLoadingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::StartLoadingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].startLoadingADSource(placementID, callbackJson);
|
||||
}
|
||||
static public void FinishLoadingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::FinishLoadingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].finishLoadingADSource(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void FailToLoadADSource(string placementID,string callbackJson, Dictionary<string, object> errorDict)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::FailToLoadADSource()");
|
||||
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].failToLoadADSource(placementID,callbackJson,(string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static public void StartBiddingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::StartBiddingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].startBiddingADSource(placementID, callbackJson);
|
||||
}
|
||||
static public void FinishBiddingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::FinishBiddingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].finishBiddingADSource(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void FailBiddingADSource(string placementID, string callbackJson,Dictionary<string, object> errorDict)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::FailBiddingADSource()");
|
||||
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].failBiddingADSource(placementID,callbackJson,(string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
// Auto
|
||||
static public void addAutoLoadAdPlacementID(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::addAutoLoadAdPlacementID(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "addAutoLoadAdPlacementID:callback:", new object[]{placementID}, true);
|
||||
}
|
||||
|
||||
static public void removeAutoLoadAdPlacementID(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::removeAutoLoadAdPlacementID(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "removeAutoLoadAdPlacementID:", new object[]{placementID});
|
||||
}
|
||||
static public bool autoLoadSplashAdReadyForPlacementID(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::autoLoadSplashAdReadyForPlacementID(" + placementID + ")");
|
||||
|
||||
return ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "autoLoadSplashAdReadyForPlacementID:", new object[]{placementID});
|
||||
}
|
||||
static public string getAutoValidAdCaches(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::getAutoValidAdCaches");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "getAutoValidAdCaches:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public string checkAutoAdStatus(string placementID) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::checkAutoAdStatus(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "checkAutoAdStatus:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public void setAutoLocalExtra(string placementID, string customData)
|
||||
{
|
||||
|
||||
Debug.Log("Unity: ATSplashAdWrapper::setAutoLocalExtra(" + placementID + customData + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "setAutoLocalExtra:customDataJSONString:", new object[] {placementID, customData != null ? customData : ""});
|
||||
}
|
||||
|
||||
static public void entryAutoAdScenarioWithPlacementID(string placementID, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::entryAutoAdScenarioWithPlacementID(" + placementID + scenarioID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "entryAutoAdScenarioWithPlacementID:scenarioID:", new object[]{placementID, scenarioID});
|
||||
}
|
||||
|
||||
static public void showAutoSplashAd(string placementID, string mapJson) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::showAutoSplashAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "showAutoSplashAd:extraJsonString:", new object[]{placementID, mapJson});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7daeafef5bd994a159a64f1040af4a67
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,103 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AOT;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
using System;
|
||||
|
||||
public class ATUnityCBridge {
|
||||
public delegate void CCallBack(string wrapperClass, string msg);
|
||||
|
||||
#if UNITY_IOS || UNITY_IPHONE
|
||||
[DllImport("__Internal")]
|
||||
extern static bool at_message_from_unity(string msg, CCallBack callback);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
extern static int at_get_message_for_unity(string msg, CCallBack callback);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
extern static string at_get_string_message_for_unity(string msg, CCallBack callback);
|
||||
#endif
|
||||
|
||||
[MonoPInvokeCallback(typeof(CCallBack))]
|
||||
static public void MessageFromC(string wrapperClass, string msg) {
|
||||
Debug.Log("Unity: ATUnityCBridge::MessageFromC(" + wrapperClass + "," + msg + ")");
|
||||
JsonData jsonData = JsonMapper.ToObject(msg);
|
||||
if (wrapperClass.Equals("ATRewardedVideoWrapper")) {
|
||||
Debug.Log("Unity: ATUnityCBridge::MessageFromC(), hit rv");
|
||||
ATRewardedVideoWrapper.InvokeCallback(jsonData);
|
||||
} else if (wrapperClass.Equals("ATNativeAdWrapper")) {
|
||||
ATNativeAdWrapper.InvokeCallback(jsonData);
|
||||
} else if (wrapperClass.Equals("ATInterstitialAdWrapper")) {
|
||||
ATInterstitialAdWrapper.InvokeCallback(jsonData);
|
||||
} else if (wrapperClass.Equals("ATBannerAdWrapper")) {
|
||||
ATBannerAdWrapper.InvokeCallback(jsonData);
|
||||
} else if (wrapperClass.Equals("ATNativeBannerAdWrapper")) {
|
||||
ATNativeBannerAdWrapper.InvokeCallback(jsonData);
|
||||
} else if (wrapperClass.Equals("ATSplashAdWrapper")) {
|
||||
ATSplashAdWrapper.InvokeCallback(jsonData);
|
||||
}
|
||||
}
|
||||
|
||||
static public bool SendMessageToC(string className, string selector, object[] arguments) {
|
||||
return SendMessageToC(className, selector, arguments, false);
|
||||
}
|
||||
|
||||
static public int GetMessageFromC(string className, string selector, object[] arguments) {
|
||||
Debug.Log("Unity: ATUnityCBridge::GetMessageFromC()");
|
||||
Dictionary<string, object> msgDict = new Dictionary<string, object>();
|
||||
msgDict.Add("class", className);
|
||||
msgDict.Add("selector", selector);
|
||||
msgDict.Add("arguments", arguments);
|
||||
#if UNITY_IOS || UNITY_IPHONE
|
||||
return at_get_message_for_unity(JsonMapper.ToJson(msgDict), null);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static public string GetStringMessageFromC(string className, string selector, object[] arguments) {
|
||||
Debug.Log("Unity: ATUnityCBridge::GetStringMessageFromC()");
|
||||
Dictionary<string, object> msgDict = new Dictionary<string, object>();
|
||||
msgDict.Add("class", className);
|
||||
msgDict.Add("selector", selector);
|
||||
msgDict.Add("arguments", arguments);
|
||||
#if UNITY_IOS || UNITY_IPHONE
|
||||
return at_get_string_message_for_unity(JsonMapper.ToJson(msgDict), null);
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
static public bool SendMessageToC(string className, string selector, object[] arguments, bool carryCallback) {
|
||||
Debug.Log("Unity: ATUnityCBridge::SendMessageToC()");
|
||||
Dictionary<string, object> msgDict = new Dictionary<string, object>();
|
||||
msgDict.Add("class", className);
|
||||
msgDict.Add("selector", selector);
|
||||
msgDict.Add("arguments", arguments);
|
||||
CCallBack callback = null;
|
||||
if (carryCallback) callback = MessageFromC;
|
||||
#if UNITY_IOS || UNITY_IPHONE
|
||||
return at_message_from_unity(JsonMapper.ToJson(msgDict), callback);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_IOS || UNITY_IPHONE
|
||||
[DllImport("__Internal")]
|
||||
extern static bool at_message_from_unity(string msg, Func<string, int> callback);
|
||||
#endif
|
||||
static public void SendMessageToCWithCallBack(string className, string selector, object[] arguments, Func<string, int> callback)
|
||||
{
|
||||
Debug.Log("Unity: ATUnityCBridge::SendMessageToCWithCallBack()");
|
||||
Dictionary<string, object> msgDict = new Dictionary<string, object>();
|
||||
msgDict.Add("class", className);
|
||||
msgDict.Add("selector", selector);
|
||||
msgDict.Add("arguments", arguments);
|
||||
#if UNITY_IOS || UNITY_IPHONE
|
||||
at_message_from_unity(JsonMapper.ToJson(msgDict), callback);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7506b10016ed445f48eccd1aa58c94b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user