123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using AnyThinkAds.Common;
- using AnyThinkAds.Api;
- using AnyThinkAds.ThirdParty.LitJson;
- namespace AnyThinkAds.iOS {
- public class ATRewardedVideoAdClient : IATRewardedVideoAdClient {
- public event EventHandler<ATAdEventArgs> onAdLoadEvent;
- public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
- public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
- public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
- public event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
- public event EventHandler<ATAdRewardEventArgs> onAdVideoCloseEvent;
- public event EventHandler<ATAdEventArgs> onAdClickEvent;
- public event EventHandler<ATAdEventArgs> onRewardEvent;
- public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
- public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
- public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
- public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
- public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
- public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
- public event EventHandler<ATAdEventArgs> onPlayAgainStart;
- public event EventHandler<ATAdEventArgs> onPlayAgainEnd;
- public event EventHandler<ATAdErrorEventArgs> onPlayAgainFailure;
- public event EventHandler<ATAdEventArgs> onPlayAgainClick;
- public event EventHandler<ATAdEventArgs> onPlayAgainReward;
- private ATRewardedVideoListener anyThinkListener;
- public void addsetting (string placementId,string json){
- //todo...
- }
- public void setListener(ATRewardedVideoListener listener) {
- Debug.Log("Unity: ATRewardedVideoAdClient::setListener()");
- anyThinkListener = listener;
- }
- public void loadVideoAd(string placementId, string mapJson) {
- Debug.Log("Unity: ATRewardedVideoAdClient::loadVideoAd()");
- ATRewardedVideoWrapper.setClientForPlacementID(placementId, this);
- ATRewardedVideoWrapper.loadRewardedVideo(placementId, mapJson);
- }
- public bool hasAdReady(string placementId) {
- Debug.Log("Unity: ATRewardedVideoAdClient::hasAdReady()");
- return ATRewardedVideoWrapper.isRewardedVideoReady(placementId);
- }
- //To be implemented
- public void setUserData(string placementId, string userId, string customData) {
- Debug.Log("Unity: ATRewardedVideoAdClient::setUserData()");
- }
- public void showAd(string placementId, string mapJson) {
- Debug.Log("Unity: ATRewardedVideoAdClient::showAd()");
- ATRewardedVideoWrapper.showRewardedVideo(placementId, mapJson);
- }
- public void cleanAd(string placementId) {
- Debug.Log("Unity: ATRewardedVideoAdClient::cleanAd()");
- ATRewardedVideoWrapper.clearCache();
- }
- public void onApplicationForces(string placementId) {
- Debug.Log("Unity: ATRewardedVideoAdClient::onApplicationForces()");
- }
- public void onApplicationPasue(string placementId) {
- Debug.Log("Unity: ATRewardedVideoAdClient::onApplicationPasue()");
- }
- public string checkAdStatus(string placementId) {
- Debug.Log("Unity: ATRewardedVideoAdClient::checkAdStatus()");
- return ATRewardedVideoWrapper.checkAdStatus(placementId);
- }
- public void entryScenarioWithPlacementID(string placementId, string scenarioID){
- Debug.Log("Unity: ATRewardedVideoAdClient::entryScenarioWithPlacementID()");
- ATRewardedVideoWrapper.entryScenarioWithPlacementID(placementId,scenarioID);
- }
- public string getValidAdCaches(string placementId)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient::getValidAdCaches()");
- return ATRewardedVideoWrapper.getValidAdCaches(placementId);
- }
- // Auto
- public void addAutoLoadAdPlacementID(string[] placementIDList)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient:addAutoLoadAdPlacementID()");
- if (placementIDList != null && placementIDList.Length > 0)
- {
- foreach (string placementID in placementIDList)
- {
- ATRewardedVideoWrapper.setClientForPlacementID(placementID, this);
- }
- string placementIDListString = JsonMapper.ToJson(placementIDList);
- ATRewardedVideoWrapper.addAutoLoadAdPlacementID(placementIDListString);
- Debug.Log("addAutoLoadAdPlacementID, placementIDList === " + placementIDListString);
- }
- else
- {
- Debug.Log("addAutoLoadAdPlacementID, placementIDList = null");
- }
- }
- public void removeAutoLoadAdPlacementID(string placementId)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient:removeAutoLoadAdPlacementID()");
- ATRewardedVideoWrapper.removeAutoLoadAdPlacementID(placementId);
- }
- public bool autoLoadRewardedVideoReadyForPlacementID(string placementId)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient:autoLoadRewardedVideoReadyForPlacementID()");
- return ATRewardedVideoWrapper.autoLoadRewardedVideoReadyForPlacementID(placementId);
- }
- public string getAutoValidAdCaches(string placementId)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient:getAutoValidAdCaches()");
- return ATRewardedVideoWrapper.getAutoValidAdCaches(placementId);
- }
- public string checkAutoAdStatus(string placementId) {
- Debug.Log("Unity: ATRewardedVideoAdClient::checkAutoAdStatus()");
- return ATRewardedVideoWrapper.checkAutoAdStatus(placementId);
- }
- public void setAutoLocalExtra(string placementId, string mapJson)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient:setAutoLocalExtra()");
- ATRewardedVideoWrapper.setAutoLocalExtra(placementId, mapJson);
- }
- public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient:entryAutoAdScenarioWithPlacementID()");
- ATRewardedVideoWrapper.entryAutoAdScenarioWithPlacementID(placementId, scenarioID);
- }
- public void showAutoAd(string placementId, string mapJson)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient::showAutoAd()");
- ATRewardedVideoWrapper.showAutoRewardedVideo(placementId, mapJson);
- }
- //auto callbacks
- public void startLoadingADSource(string placementId, string callbackJson)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient::startLoadingADSource()");
- onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
- }
- public void finishLoadingADSource(string placementId, string callbackJson)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient::finishLoadingADSource()");
- onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
- }
- public void failToLoadADSource(string placementId, string callbackJson,string code, string error)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient::failToLoadADSource()");
- onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
- }
- public void startBiddingADSource(string placementId, string callbackJson)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient::startBiddingADSource()");
- onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
- }
- public void finishBiddingADSource(string placementId, string callbackJson)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient::finishBiddingADSource()");
- onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
- }
- public void failBiddingADSource(string placementId, string callbackJson,string code, string error)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient::failBiddingADSource()");
- onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
- }
- //Callbacks
- public void onRewardedVideoAdLoaded(string placementId) {
- Debug.Log("Unity: ATRewardedVideoAdClient::onRewardedVideoAdLoaded()");
- onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
- }
- public void onRewardedVideoAdFailed(string placementId, string code, string error) {
- Debug.Log("Unity: ATRewardedVideoAdClient::onRewardedVideoAdFailed()");
- onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
- }
- public void onRewardedVideoAdPlayStart(string placementId, string callbackJson) {
- Debug.Log("Unity: ATRewardedVideoAdClient::onRewardedVideoAdPlayStart()");
- onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
- }
- public void onRewardedVideoAdPlayEnd(string placementId, string callbackJson) {
- Debug.Log("Unity: ATRewardedVideoAdClient::onRewardedVideoAdPlayEnd()");
- onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
- }
- public void onRewardedVideoAdPlayFailed(string placementId, string code, string error) {
- Debug.Log("Unity: ATRewardedVideoAdClient::onRewardedVideoAdPlayFailed()");
- onAdVideoFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
- }
- public void onRewardedVideoAdClosed(string placementId, bool isRewarded, string callbackJson) {
- Debug.Log("Unity: ATRewardedVideoAdClient::onRewardedVideoAdClosed()");
- onAdVideoCloseEvent?.Invoke(this, new ATAdRewardEventArgs(placementId, callbackJson, isRewarded));
- }
- public void onRewardedVideoAdPlayClicked(string placementId, string callbackJson) {
- Debug.Log("Unity: ATRewardedVideoAdClient::onRewardedVideoAdPlayClicked()");
- onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
- }
- public void onRewardedVideoReward(string placementId, string callbackJson) {
- Debug.Log("Unity: ATRewardedVideoAdClient::onRewardedVideoReward()");
- onRewardEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
- }
- //--------again callback-------
- public void onRewardedVideoAdAgainPlayStart(string placementId, string callbackJson)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient::onRewardedVideoAdAgainPlayStart()");
- onPlayAgainStart?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
- }
- public void onRewardedVideoAdAgainPlayEnd(string placementId, string callbackJson)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient::onRewardedVideoAdAgainPlayEnd()");
- onPlayAgainEnd?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
- }
- public void onRewardedVideoAdAgainPlayFailed(string placementId, string code, string error)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient::onRewardedVideoAdAgainPlayFailed()");
- onPlayAgainFailure?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
- }
- public void onRewardedVideoAdAgainPlayClicked(string placementId, string callbackJson)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient::onRewardedVideoAdAgainPlayClicked()");
- onPlayAgainClick?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
- }
- public void onAgainReward(string placementId, string callbackJson)
- {
- Debug.Log("Unity: ATRewardedVideoAdClient::onAgainReward()");
- onPlayAgainReward?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
- }
- }
- }
|