fix:1、删除上一个sdk,更换新的。2、删除了max广告
This commit is contained in:
@@ -0,0 +1,493 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using AnyThinkAds.Api;
|
||||
using AnyThinkAds.Common;
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
#pragma warning disable 0067
|
||||
namespace AnyThinkAds
|
||||
{
|
||||
public class ATAdsClientFactory
|
||||
{
|
||||
public static IATBannerAdClient BuildBannerAdClient()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// Testing UNITY_EDITOR first because the editor also responds to the currently
|
||||
// selected platform.
|
||||
#elif UNITY_ANDROID
|
||||
return new AnyThinkAds.Android.ATBannerAdClient();
|
||||
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
|
||||
return new AnyThinkAds.iOS.ATBannerAdClient();
|
||||
#else
|
||||
|
||||
#endif
|
||||
return new UnityBannerClient();
|
||||
}
|
||||
|
||||
public static IATInterstitialAdClient BuildInterstitialAdClient()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// Testing UNITY_EDITOR first because the editor also responds to the currently
|
||||
// selected platform.
|
||||
#elif UNITY_ANDROID
|
||||
return new AnyThinkAds.Android.ATInterstitialAdClient();
|
||||
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
|
||||
return new AnyThinkAds.iOS.ATInterstitialAdClient();
|
||||
#else
|
||||
|
||||
#endif
|
||||
return new UnityInterstitialClient();
|
||||
}
|
||||
|
||||
public static IATNativeAdClient BuildNativeAdClient()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// Testing UNITY_EDITOR first because the editor also responds to the currently
|
||||
// selected platform.
|
||||
#elif UNITY_ANDROID
|
||||
return new AnyThinkAds.Android.ATNativeAdClient();
|
||||
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
|
||||
return new AnyThinkAds.iOS.ATNativeAdClient();
|
||||
#else
|
||||
|
||||
#endif
|
||||
return new UnityNativeAdClient();
|
||||
}
|
||||
|
||||
public static IATNativeBannerAdClient BuildNativeBannerAdClient()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// Testing UNITY_EDITOR first because the editor also responds to the currently
|
||||
// selected platform.
|
||||
#elif UNITY_ANDROID
|
||||
return new AnyThinkAds.Android.ATNativeBannerAdClient();
|
||||
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
|
||||
return new AnyThinkAds.iOS.ATNativeBannerAdClient();
|
||||
#else
|
||||
|
||||
#endif
|
||||
return new UnityNativeBannerAdClient();
|
||||
}
|
||||
|
||||
public static IATRewardedVideoAdClient BuildRewardedVideoAdClient()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// Testing UNITY_EDITOR first because the editor also responds to the currently
|
||||
// selected platform.
|
||||
|
||||
#elif UNITY_ANDROID
|
||||
return new AnyThinkAds.Android.ATRewardedVideoAdClient();
|
||||
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
|
||||
return new AnyThinkAds.iOS.ATRewardedVideoAdClient();
|
||||
#else
|
||||
|
||||
#endif
|
||||
return new UnityRewardedVideoAdClient();
|
||||
}
|
||||
|
||||
public static IATSDKAPIClient BuildSDKAPIClient()
|
||||
{
|
||||
Debug.Log("BuildSDKAPIClient");
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log("Unity Editor");
|
||||
// Testing UNITY_EDITOR first because the editor also responds to the currently
|
||||
// selected platform.
|
||||
|
||||
#elif UNITY_ANDROID
|
||||
return new AnyThinkAds.Android.ATSDKAPIClient();
|
||||
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
|
||||
Debug.Log("Unity:ATAdsClientFactory::Build iOS Client");
|
||||
return new AnyThinkAds.iOS.ATSDKAPIClient();
|
||||
#else
|
||||
|
||||
#endif
|
||||
return new UnitySDKAPIClient();
|
||||
}
|
||||
|
||||
public static IATDownloadClient BuildDownloadClient()
|
||||
{
|
||||
Debug.Log("BuildDownloadClient");
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log("Unity Editor");
|
||||
// Testing UNITY_EDITOR first because the editor also responds to the currently
|
||||
// selected platform.
|
||||
|
||||
#elif UNITY_ANDROID
|
||||
return new AnyThinkAds.Android.ATDownloadClient();
|
||||
|
||||
#else
|
||||
|
||||
#endif
|
||||
return new UnityDownloadClient();
|
||||
}
|
||||
|
||||
public static IATSplashAdClient BuildSplashAdClient()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// Testing UNITY_EDITOR first because the editor also responds to the currently
|
||||
// selected platform.
|
||||
#elif UNITY_ANDROID
|
||||
return new AnyThinkAds.Android.ATSplashAdClient();
|
||||
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
|
||||
//TODO iOS返回开屏client
|
||||
return new AnyThinkAds.iOS.ATSplashAdClient();
|
||||
#else
|
||||
#endif
|
||||
return new UnitySplashClient();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UnitySDKAPIClient:IATSDKAPIClient
|
||||
{
|
||||
public void initSDK(string appId, string appkey){}
|
||||
public void initSDK(string appId, string appkey, ATSDKInitListener listener){ }
|
||||
public void getUserLocation(ATGetUserLocationListener listener){ }
|
||||
public void setGDPRLevel(int level){ }
|
||||
public void showGDPRAuth(){ }
|
||||
public void showGDPRConsentDialog(ATConsentDismissListener listener){ }
|
||||
public void addNetworkGDPRInfo(int networkType, string mapJson){ }
|
||||
public void setChannel(string channel){ }
|
||||
public void setSubChannel(string subchannel){ }
|
||||
public void initCustomMap(string cutomMap){ }
|
||||
public void setCustomDataForPlacementID(string customData, string placementID){ }
|
||||
public void setLogDebug(bool isDebug){ }
|
||||
public int getGDPRLevel(){ return ATSDKAPI.PERSONALIZED; }
|
||||
public bool isEUTraffic() { return false; }
|
||||
public void deniedUploadDeviceInfo(string deniedInfo) { }
|
||||
public void setExcludeBundleIdArray(string bundleIds) { }
|
||||
public void setExcludeAdSourceIdArrayForPlacementID(string placementID, string adsourceIds) { }
|
||||
public void setSDKArea(int area) { }
|
||||
public void getArea(ATGetAreaListener listener) { }
|
||||
public void setWXStatus(bool install) { }
|
||||
public void setLocation(double longitude, double latitude) { }
|
||||
public void showDebuggerUI() {}
|
||||
public void showDebuggerUI(string debugKey) {}
|
||||
}
|
||||
|
||||
class UnityBannerClient:IATBannerAdClient
|
||||
{
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdAutoRefreshEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdAutoRefreshFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseButtonTappedEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
ATBannerAdListener listener;
|
||||
public void loadBannerAd(string unitId, string mapJson){
|
||||
if(listener != null)
|
||||
{
|
||||
listener.onAdLoadFail(unitId, "-1", "Must run on Android or IOS platform!");
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener(ATBannerAdListener listener)
|
||||
{
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public string checkAdStatus(string unitId) { return ""; }
|
||||
|
||||
public void showBannerAd(string unitId, string position){ }
|
||||
|
||||
public void showBannerAd(string unitId, string position, string mapJson){ }
|
||||
|
||||
public void showBannerAd(string unitId, ATRect rect){ }
|
||||
|
||||
public void showBannerAd(string unitId, ATRect rect, string mapJson){ }
|
||||
|
||||
public void cleanBannerAd(string unitId){ }
|
||||
|
||||
public void hideBannerAd(string unitId){ }
|
||||
|
||||
public void showBannerAd(string unitId){ }
|
||||
|
||||
public void cleanCache(string unitId){}
|
||||
|
||||
public string getValidAdCaches(string unitId) { return ""; }
|
||||
}
|
||||
|
||||
class UnityInterstitialClient : IATInterstitialAdClient
|
||||
{
|
||||
ATInterstitialAdListener listener;
|
||||
#pragma warning disable 220
|
||||
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdShowEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdShowFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
|
||||
public void loadInterstitialAd(string unitId, string mapJson){
|
||||
if (listener != null)
|
||||
{
|
||||
listener.onInterstitialAdLoadFail(unitId, "-1", "Must run on Android or IOS platform!");
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener(ATInterstitialAdListener listener){
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public bool hasInterstitialAdReady(string unitId) { return false; }
|
||||
|
||||
public string checkAdStatus(string unitId) { return ""; }
|
||||
|
||||
public void showInterstitialAd(string unitId, string mapJson){}
|
||||
|
||||
public void cleanCache(string unitId){}
|
||||
|
||||
public string getValidAdCaches(string unitId) { return ""; }
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID){}
|
||||
|
||||
|
||||
public void addAutoLoadAdPlacementID(string[] placementIDList) {}
|
||||
|
||||
public void removeAutoLoadAdPlacementID(string placementId){}
|
||||
|
||||
public bool autoLoadInterstitialAdReadyForPlacementID(string placementId){return false;}
|
||||
|
||||
public string getAutoValidAdCaches(string placementId){return "";}
|
||||
public string checkAutoAdStatus(string unitId) { return ""; }
|
||||
|
||||
|
||||
public void setAutoLocalExtra(string placementId, string mapJson){}
|
||||
|
||||
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID){}
|
||||
|
||||
public void showAutoAd(string placementId, string mapJson){}
|
||||
|
||||
}
|
||||
|
||||
class UnityNativeAdClient : IATNativeAdClient
|
||||
{
|
||||
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
|
||||
ATNativeAdListener listener;
|
||||
public void loadNativeAd(string unitId, string mapJson){
|
||||
if(listener != null)
|
||||
{
|
||||
listener.onAdLoadFail(unitId, "-1", "Must run on Android or IOS platform!");
|
||||
}
|
||||
}
|
||||
|
||||
public bool hasAdReady(string unitId) { return false; }
|
||||
|
||||
public string checkAdStatus(string unitId) { return ""; }
|
||||
|
||||
public string getValidAdCaches(string unitId) { return ""; }
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID){}
|
||||
|
||||
|
||||
public void setListener(ATNativeAdListener listener){
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void renderAdToScene(string unitId, ATNativeAdView anyThinkNativeAdView){}
|
||||
|
||||
public void renderAdToScene(string unitId, ATNativeAdView anyThinkNativeAdView, string mapJson){}
|
||||
|
||||
public void cleanAdView(string unitId, ATNativeAdView anyThinkNativeAdView){}
|
||||
|
||||
public void onApplicationForces(string unitId, ATNativeAdView anyThinkNativeAdView){}
|
||||
|
||||
public void onApplicationPasue(string unitId, ATNativeAdView anyThinkNativeAdView){}
|
||||
|
||||
public void cleanCache(string unitId){}
|
||||
|
||||
public void setLocalExtra(string unitid, string mapJson){}
|
||||
}
|
||||
|
||||
class UnityNativeBannerAdClient : IATNativeBannerAdClient
|
||||
{
|
||||
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
ATNativeBannerAdListener listener;
|
||||
public void loadAd(string unitId, string mapJson){
|
||||
if(listener != null)
|
||||
{
|
||||
listener.onAdLoadFail(unitId, "-1", "Must run on Android or IOS platform!");
|
||||
}
|
||||
}
|
||||
|
||||
public bool adReady(string unitId) { return false; }
|
||||
|
||||
public void setListener(ATNativeBannerAdListener listener){
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void showAd(string unitId, ATRect rect, Dictionary<string, string> pairs){}
|
||||
|
||||
public void removeAd(string unitId){}
|
||||
}
|
||||
|
||||
class UnityRewardedVideoAdClient : 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;
|
||||
|
||||
ATRewardedVideoListener listener;
|
||||
public void loadVideoAd(string unitId, string mapJson){
|
||||
if (listener != null)
|
||||
{
|
||||
listener.onRewardedVideoAdLoadFail(unitId, "-1", "Must run on Android or IOS platform!");
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener(ATRewardedVideoListener listener){
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public bool hasAdReady(string unitId) { return false; }
|
||||
|
||||
public string checkAdStatus(string unitId) { return ""; }
|
||||
|
||||
public string getValidAdCaches(string unitId) { return ""; }
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID){}
|
||||
|
||||
public void showAd(string unitId, string mapJson){}
|
||||
|
||||
public void addAutoLoadAdPlacementID(string[] placementIDList) {}
|
||||
|
||||
public void removeAutoLoadAdPlacementID(string placementId){}
|
||||
|
||||
public bool autoLoadRewardedVideoReadyForPlacementID(string placementId){return false;}
|
||||
|
||||
public string getAutoValidAdCaches(string placementId){return "";}
|
||||
|
||||
public string checkAutoAdStatus(string unitId) { return ""; }
|
||||
|
||||
public void setAutoLocalExtra(string placementId, string mapJson){}
|
||||
|
||||
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID){}
|
||||
|
||||
public void showAutoAd(string placementId, string mapJson){}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
class UnityDownloadClient : IATDownloadClient
|
||||
{
|
||||
public void setListener(ATDownloadAdListener listener)
|
||||
{
|
||||
Debug.Log("Must run on Android platform");
|
||||
}
|
||||
}
|
||||
|
||||
class UnitySplashClient : IATSplashAdClient
|
||||
{
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadTimeoutEvent;
|
||||
public event EventHandler<ATAdEventArgs> onDeeplinkEvent;
|
||||
public event EventHandler<ATAdEventArgs> onDownloadConfirmEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdShowEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
// called if the ad has failed to be shown
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdShowFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
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;
|
||||
// public void loadSplashAd(string placementId, string mapJson) {}
|
||||
public void loadSplashAd(string placementId, int fetchAdTimeout, string defaultAdSourceConfig, string mapJson) {}
|
||||
public void setListener(ATSplashAdListener listener) {}
|
||||
|
||||
public bool hasSplashAdReady(string placementId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId) {
|
||||
return "";
|
||||
}
|
||||
|
||||
public void showSplashAd(string placementId, string mapJson) {}
|
||||
|
||||
/***
|
||||
* 获取所有可用缓存广告
|
||||
*/
|
||||
public string getValidAdCaches(string placementId) {
|
||||
return "";
|
||||
}
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID) {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c8a4f3522d7148ee9c8a9ead3279202
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da19b2447f2434d0b83899d1751efc3a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AnyThinkAds.Api;
|
||||
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATAreaListener : AndroidJavaProxy
|
||||
{
|
||||
ATGetAreaListener mListener;
|
||||
public ATAreaListener(ATGetAreaListener listener): base("com.thinkup.unitybridge.sdkinit.AreaCallbackListener")
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
|
||||
public void onResultCallback(string area)
|
||||
{
|
||||
if (mListener != null)
|
||||
{
|
||||
mListener.onArea(area);
|
||||
}
|
||||
}
|
||||
|
||||
public void onErrorCallback(string s)
|
||||
{
|
||||
if (mListener != null)
|
||||
{
|
||||
mListener.onError(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34e0bea6b21914047977e0bb6fc80d08
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,314 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
#pragma warning disable 0067
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATBannerAdClient : AndroidJavaProxy, IATBannerAdClient
|
||||
{
|
||||
|
||||
private Dictionary<string, AndroidJavaObject> bannerHelperMap = new Dictionary<string, AndroidJavaObject>();
|
||||
|
||||
|
||||
private ATBannerAdListener anyThinkListener;
|
||||
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
|
||||
// triggers when a banner ad has failed to load
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
|
||||
// triggers when a banner ad generates an impression
|
||||
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
|
||||
|
||||
// triggers when the user clicks a banner ad
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
|
||||
// triggers when the ad refreshes
|
||||
public event EventHandler<ATAdEventArgs> onAdAutoRefreshEvent;
|
||||
|
||||
// triggers when the ad fails to auto refresh
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdAutoRefreshFailureEvent;
|
||||
|
||||
// triggers when the banner ad is closed
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
|
||||
// triggers when the users closes the ad via the button
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseButtonTappedEvent;
|
||||
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
|
||||
public ATBannerAdClient() : base("com.thinkup.unitybridge.banner.BannerListener")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void loadBannerAd(string placementId, string mapJson)
|
||||
{
|
||||
|
||||
//如果不存在则直接创建对应广告位的helper
|
||||
if(!bannerHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
AndroidJavaObject bannerHelper = new AndroidJavaObject(
|
||||
"com.thinkup.unitybridge.banner.BannerHelper", this);
|
||||
bannerHelper.Call("initBanner", placementId);
|
||||
bannerHelperMap.Add(placementId, bannerHelper);
|
||||
Debug.Log("ATBannerAdClient : no exit helper ,create helper ");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Debug.Log("ATBannerAdClient : loadBannerAd ");
|
||||
bannerHelperMap[placementId].Call("loadBannerAd", mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATBannerAdClient : error."+e.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId)
|
||||
{
|
||||
string adStatusJsonString = "";
|
||||
Debug.Log("ATBannerAdClient : checkAdStatus....");
|
||||
try
|
||||
{
|
||||
if (bannerHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
adStatusJsonString = bannerHelperMap[placementId].Call<string>("checkAdStatus");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATBannerAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
string validAdCachesString = "";
|
||||
Debug.Log("ATBannerAdClient : getValidAdCaches....");
|
||||
try
|
||||
{
|
||||
if (bannerHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
validAdCachesString = bannerHelperMap[placementId].Call<string>("getValidAdCaches");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATBannerAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return validAdCachesString;
|
||||
}
|
||||
|
||||
|
||||
public void setListener(ATBannerAdListener listener)
|
||||
{
|
||||
anyThinkListener = listener;
|
||||
}
|
||||
|
||||
|
||||
public void showBannerAd(string placementId, string position, string mapJson)
|
||||
{
|
||||
Debug.Log("ATBannerAdClient : showBannerAd by position" );
|
||||
//todo
|
||||
try
|
||||
{
|
||||
if (bannerHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
this.bannerHelperMap[placementId].Call("showBannerAd", position, mapJson);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATBannerAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void showBannerAd(string placementId, ATRect rect, string mapJson)
|
||||
{
|
||||
Debug.Log("ATBannerAdClient : showBannerAd " );
|
||||
|
||||
try{
|
||||
if (bannerHelperMap.ContainsKey(placementId)) {
|
||||
this.bannerHelperMap[placementId].Call ("showBannerAd", rect.x, rect.y, rect.width, rect.height, mapJson, rect.usesPixel);
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATBannerAdClient : error."+e.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanBannerAd(string placementId)
|
||||
{
|
||||
|
||||
Debug.Log("ATBannerAdClient : cleanBannerAd" );
|
||||
|
||||
try{
|
||||
if (bannerHelperMap.ContainsKey(placementId)) {
|
||||
this.bannerHelperMap[placementId].Call ("cleanBannerAd");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATBannerAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void hideBannerAd(string placementId)
|
||||
{
|
||||
Debug.Log("ATBannerAdClient : hideBannerAd");
|
||||
|
||||
try
|
||||
{
|
||||
if (bannerHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
this.bannerHelperMap[placementId].Call("hideBannerAd");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATBannerAdClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
//针对已有的进行展示,没有就调用该方法无效
|
||||
public void showBannerAd(string placementId)
|
||||
{
|
||||
Debug.Log("ATBannerAdClient : showBannerAd ");
|
||||
|
||||
try
|
||||
{
|
||||
if (bannerHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
this.bannerHelperMap[placementId].Call("showBannerAd");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATBannerAdClient : error." + e.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanCache(string placementId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//广告加载成功
|
||||
public void onBannerLoaded(string placementId)
|
||||
{
|
||||
Debug.Log("onBannerLoaded...unity3d.");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
}
|
||||
|
||||
//广告加载失败
|
||||
public void onBannerFailed(string placementId,string code, string error)
|
||||
{
|
||||
Debug.Log("onBannerFailed...unity3d.");
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
//广告点击
|
||||
public void onBannerClicked(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onBannerClicked...unity3d.");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
//广告展示
|
||||
public void onBannerShow(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onBannerShow...unity3d.");
|
||||
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
//广告关闭
|
||||
public void onBannerClose(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onBannerClose...unity3d.");
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
//广告关闭
|
||||
public void onBannerAutoRefreshed(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onBannerAutoRefreshed...unity3d.");
|
||||
onAdAutoRefreshEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
//广告自动刷新失败
|
||||
public void onBannerAutoRefreshFail(string placementId, string code, string msg)
|
||||
{
|
||||
Debug.Log("onBannerAutoRefreshFail...unity3d.");
|
||||
onAdAutoRefreshFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, msg));
|
||||
}
|
||||
|
||||
// Adsource Listener
|
||||
public void onAdSourceBiddingAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
|
||||
public void onAdSourceAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c7bec7d500e74ca995affc2bd45de2c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,93 @@
|
||||
using UnityEngine;
|
||||
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATDownloadClient : AndroidJavaProxy,IATDownloadClient
|
||||
{
|
||||
|
||||
private AndroidJavaObject downloadHelper;
|
||||
|
||||
|
||||
private ATDownloadAdListener anyThinkListener;
|
||||
|
||||
public ATDownloadClient() : base("com.thinkup.unitybridge.download.DownloadListener")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void setListener(ATDownloadAdListener listener)
|
||||
{
|
||||
Debug.Log("ATDownloadClient : setListener");
|
||||
anyThinkListener = listener;
|
||||
|
||||
if (downloadHelper == null)
|
||||
{
|
||||
downloadHelper = new AndroidJavaObject(
|
||||
"com.thinkup.unitybridge.download.DownloadHelper", this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void onDownloadStart(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
|
||||
{
|
||||
Debug.Log("onDownloadStart...unity3d.");
|
||||
if(anyThinkListener != null){
|
||||
anyThinkListener.onDownloadStart(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onDownloadUpdate(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
|
||||
{
|
||||
Debug.Log("onDownloadUpdate...unity3d.");
|
||||
if (anyThinkListener != null)
|
||||
{
|
||||
anyThinkListener.onDownloadUpdate(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onDownloadPause(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
|
||||
{
|
||||
Debug.Log("onDownloadPause...unity3d.");
|
||||
if (anyThinkListener != null)
|
||||
{
|
||||
anyThinkListener.onDownloadPause(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onDownloadFinish(string placementId, string callbackJson, long totalBytes, string fileName, string appName)
|
||||
{
|
||||
Debug.Log("onDownloadFinish...unity3d.");
|
||||
if (anyThinkListener != null)
|
||||
{
|
||||
anyThinkListener.onDownloadFinish(placementId, new ATCallbackInfo(callbackJson), totalBytes, fileName, appName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onDownloadFail(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
|
||||
{
|
||||
Debug.Log("onDownloadFail...unity3d.");
|
||||
if (anyThinkListener != null)
|
||||
{
|
||||
anyThinkListener.onDownloadFail(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onInstalled(string placementId, string callbackJson, string fileName, string appName)
|
||||
{
|
||||
Debug.Log("onInstalled...unity3d.");
|
||||
if (anyThinkListener != null)
|
||||
{
|
||||
anyThinkListener.onInstalled(placementId, new ATCallbackInfo(callbackJson), fileName, appName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c15069ef3f95a4e899d4a8d36931a17c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AnyThinkAds.Api;
|
||||
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATGDPRConsentDismissListener : AndroidJavaProxy
|
||||
{
|
||||
ATConsentDismissListener mListener;
|
||||
public ATGDPRConsentDismissListener(ATConsentDismissListener listener): base("com.thinkup.unitybridge.sdkinit.SDKConsentDismissListener")
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
public void onConsentDismiss()
|
||||
{
|
||||
if (mListener != null)
|
||||
{
|
||||
mListener.onConsentDismiss();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01aabe528bcb74cac9ab3e883dbbcae6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,427 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATInterstitialAdClient : AndroidJavaProxy,IATInterstitialAdClient
|
||||
{
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdShowEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdShowFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
|
||||
private Dictionary<string, AndroidJavaObject> interstitialHelperMap = new Dictionary<string, AndroidJavaObject>();
|
||||
|
||||
//private AndroidJavaObject videoHelper;
|
||||
private ATInterstitialAdListener anyThinkListener;
|
||||
|
||||
private AndroidJavaObject interstitialAutoAdHelper;
|
||||
|
||||
public ATInterstitialAdClient() : base("com.thinkup.unitybridge.interstitial.InterstitialListener")
|
||||
{
|
||||
interstitialAutoAdHelper = new AndroidJavaObject("com.thinkup.unitybridge.interstitial.InterstitialAutoAdHelper", this);
|
||||
}
|
||||
|
||||
|
||||
public void loadInterstitialAd(string placementId, string mapJson)
|
||||
{
|
||||
|
||||
//如果不存在则直接创建对应广告位的helper
|
||||
if(!interstitialHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
AndroidJavaObject videoHelper = new AndroidJavaObject(
|
||||
"com.thinkup.unitybridge.interstitial.InterstitialHelper", this);
|
||||
videoHelper.Call("initInterstitial", placementId);
|
||||
interstitialHelperMap.Add(placementId, videoHelper);
|
||||
Debug.Log("ATInterstitialAdClient : no exit helper ,create helper ");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Debug.Log("ATInterstitialAdClient : loadInterstitialAd ");
|
||||
interstitialHelperMap[placementId].Call("loadInterstitialAd", mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setListener(ATInterstitialAdListener listener)
|
||||
{
|
||||
anyThinkListener = listener;
|
||||
}
|
||||
|
||||
public bool hasInterstitialAdReady(string placementId)
|
||||
{
|
||||
bool isready = false;
|
||||
Debug.Log ("ATInterstitialAdClient : hasAdReady....");
|
||||
try{
|
||||
if (interstitialHelperMap.ContainsKey(placementId)) {
|
||||
isready = interstitialHelperMap[placementId].Call<bool> ("isAdReady");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
|
||||
}
|
||||
return isready;
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId)
|
||||
{
|
||||
string adStatusJsonString = "";
|
||||
Debug.Log("ATInterstitialAdClient : checkAdStatus....");
|
||||
try
|
||||
{
|
||||
if (interstitialHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
adStatusJsonString = interstitialHelperMap[placementId].Call<string>("checkAdStatus");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATInterstitialAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
|
||||
Debug.Log("ATInterstitialAdClient : entryScenarioWithPlacementID....");
|
||||
try
|
||||
{
|
||||
if (interstitialHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
interstitialHelperMap[placementId].Call("entryAdScenario", scenarioID);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATInterstitialAdClient entryScenarioWithPlacementID: error." + e.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
string validAdCachesString = "";
|
||||
Debug.Log("ATNativeAdClient : getValidAdCaches....");
|
||||
try
|
||||
{
|
||||
if (interstitialHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
validAdCachesString = interstitialHelperMap[placementId].Call<string>("getValidAdCaches");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATNativeAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return validAdCachesString;
|
||||
}
|
||||
|
||||
public void showInterstitialAd(string placementId, string jsonmap)
|
||||
{
|
||||
Debug.Log("ATInterstitialAdClient : showAd " );
|
||||
|
||||
try{
|
||||
if (interstitialHelperMap.ContainsKey(placementId)) {
|
||||
this.interstitialHelperMap[placementId].Call ("showInterstitialAd", jsonmap);
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void cleanCache(string placementId)
|
||||
{
|
||||
|
||||
Debug.Log("ATInterstitialAdClient : clean" );
|
||||
|
||||
try{
|
||||
if (interstitialHelperMap.ContainsKey(placementId)) {
|
||||
this.interstitialHelperMap[placementId].Call ("clean");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void onApplicationForces(string placementId)
|
||||
{
|
||||
Debug.Log ("onApplicationForces.... ");
|
||||
try{
|
||||
if (interstitialHelperMap.ContainsKey(placementId)) {
|
||||
this.interstitialHelperMap[placementId].Call ("onResume");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void onApplicationPasue(string placementId)
|
||||
{
|
||||
Debug.Log ("onApplicationPasue.... ");
|
||||
try{
|
||||
if (interstitialHelperMap.ContainsKey(placementId)) {
|
||||
this.interstitialHelperMap[placementId].Call ("onPause");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
//广告加载成功
|
||||
public void onInterstitialAdLoaded(string placementId)
|
||||
{
|
||||
Debug.Log("onInterstitialAdLoaded...unity3d.");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
}
|
||||
|
||||
//广告加载失败
|
||||
public void onInterstitialAdLoadFail(string placementId,string code, string error)
|
||||
{
|
||||
Debug.Log("onInterstitialAdFailed...unity3d.");
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
//开始播放
|
||||
public void onInterstitialAdVideoStart(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onInterstitialAdPlayStart...unity3d.");
|
||||
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
//结束播放
|
||||
public void onInterstitialAdVideoEnd(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onInterstitialAdPlayEnd...unity3d.");
|
||||
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
//播放失败
|
||||
public void onInterstitialAdVideoError(string placementId,string code, string error)
|
||||
{
|
||||
Debug.Log("onInterstitialAdPlayFailed...unity3d.");
|
||||
onAdVideoFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
//展示失败
|
||||
public void OnInterstitialAdFailedToShow(string placementID) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdFailedToShow()");
|
||||
onAdShowFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, "-1", "Failed to show video ad"));
|
||||
}
|
||||
|
||||
|
||||
//广告关闭
|
||||
public void onInterstitialAdClose(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onInterstitialAdClosed...unity3d.");
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
//广告点击
|
||||
public void onInterstitialAdClicked(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onInterstitialAdClicked...unity3d.");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onInterstitialAdShow(string placementId, string callbackJson){
|
||||
Debug.Log("onInterstitialAdShow...unity3d.");
|
||||
onAdShowEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
// Adsource Listener
|
||||
public void onAdSourceBiddingAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
|
||||
public void onAdSourceAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
|
||||
// Auto
|
||||
public void addAutoLoadAdPlacementID(string[] placementIDList){
|
||||
Debug.Log("Unity: ATInterstitialAdClient:addAutoLoadAdPlacementID()" + JsonMapper.ToJson(placementIDList));
|
||||
try
|
||||
{
|
||||
interstitialAutoAdHelper.Call("addPlacementIds", JsonMapper.ToJson(placementIDList));
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATInterstitialAdClient addAutoLoadAdPlacementID: error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAutoLoadAdPlacementID(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:removeAutoLoadAdPlacementID()");
|
||||
try
|
||||
{
|
||||
interstitialAutoAdHelper.Call("removePlacementIds", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATInterstitialAdClient removeAutoLoadAdPlacementID: error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public bool autoLoadInterstitialAdReadyForPlacementID(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:autoLoadInterstitialAdReadyForPlacementID()");
|
||||
bool isready = false;
|
||||
try
|
||||
{
|
||||
isready = interstitialAutoAdHelper.Call<bool>("isAdReady", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATInterstitialAdClient:autoLoadInterstitialAdReadyForPlacementID( : error." + e.Message);
|
||||
}
|
||||
return isready;
|
||||
}
|
||||
public string getAutoValidAdCaches(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:getAutoValidAdCaches()");
|
||||
string adStatusJsonString = "";
|
||||
try
|
||||
{
|
||||
adStatusJsonString = interstitialAutoAdHelper.Call<string>("getValidAdCaches", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATInterstitialAdClient:getAutoValidAdCaches() : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
public void setAutoLocalExtra(string placementId, string mapJson)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:setAutoLocalExtra()");
|
||||
try
|
||||
{
|
||||
interstitialAutoAdHelper.Call("setAdExtraData", placementId, mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATInterstitialAdClient:setAutoLocalExtra() : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:entryAutoAdScenarioWithPlacementID()");
|
||||
try
|
||||
{
|
||||
interstitialAutoAdHelper.Call("entryAdScenario", placementId, scenarioID);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATInterstitialAdClient:entryAutoAdScenarioWithPlacementID() : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void showAutoAd(string placementId, string mapJson)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient::showAutoAd()");
|
||||
try
|
||||
{
|
||||
interstitialAutoAdHelper.Call("show", placementId, mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATInterstitialAdClient:showAutoAd() : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public string checkAutoAdStatus(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:checkAutoAdStatus() : checkAutoAdStatus....");
|
||||
string adStatusJsonString = "";
|
||||
try
|
||||
{
|
||||
adStatusJsonString = interstitialAutoAdHelper.Call<string>("checkAdStatus", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATInterstitialAdClient:checkAutoAdStatus() : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2974fada499ca461fb812844f898b961
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
#if UNITY_ANDROID
|
||||
|
||||
public class ATMsgTools
|
||||
{
|
||||
private AndroidJavaObject _Plugin;
|
||||
|
||||
public ATMsgTools ()
|
||||
{
|
||||
try{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
return;
|
||||
|
||||
_Plugin = new AndroidJavaObject ("com.thinkup.unitybridge.MsgTools");
|
||||
|
||||
}catch(System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void printLogI (string msg)
|
||||
{
|
||||
try{
|
||||
|
||||
_Plugin.Call ("printLogI",msg);
|
||||
}catch(System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void printMsg (string msg)
|
||||
{
|
||||
try{
|
||||
_Plugin.Call ("pirntMsg",msg);
|
||||
}catch(System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7c6efa7c8667421bad3af1671dd777d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,342 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATNativeAdClient : AndroidJavaProxy, IATNativeAdClient
|
||||
{
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
|
||||
private Dictionary<string, AndroidJavaObject> nativeAdHelperMap = new Dictionary<string, AndroidJavaObject>();
|
||||
private ATNativeAdListener mlistener;
|
||||
|
||||
public ATNativeAdClient(): base("com.thinkup.unitybridge.nativead.NativeListener")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void loadNativeAd(string placementId, string mapJson)
|
||||
{
|
||||
Debug.Log ("loadNativeAd....jsonmap:"+mapJson);
|
||||
if(!nativeAdHelperMap.ContainsKey(placementId)){
|
||||
AndroidJavaObject nativeHelper = new AndroidJavaObject(
|
||||
"com.thinkup.unitybridge.nativead.NativeHelper", this);
|
||||
nativeHelper.Call("initNative", placementId);
|
||||
nativeAdHelperMap.Add(placementId, nativeHelper);
|
||||
}
|
||||
try{
|
||||
if (nativeAdHelperMap.ContainsKey(placementId)) {
|
||||
nativeAdHelperMap[placementId].Call ("loadNative",mapJson);
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATNativeAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool hasAdReady(string placementId)
|
||||
{
|
||||
bool isready = false;
|
||||
Debug.Log ("hasAdReady....");
|
||||
try{
|
||||
if (nativeAdHelperMap.ContainsKey(placementId)) {
|
||||
isready = nativeAdHelperMap[placementId].Call<bool> ("isAdReady");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATNativeAdClient : error."+e.Message);
|
||||
}
|
||||
return isready;
|
||||
}
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
|
||||
Debug.Log("ATNativeAdClient : entryScenarioWithPlacementID....");
|
||||
try
|
||||
{
|
||||
if (nativeAdHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
nativeAdHelperMap[placementId].Call("entryAdScenario", scenarioID);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATNativeAdClient entryScenarioWithPlacementID: error." + e.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId)
|
||||
{
|
||||
string adStatusJsonString = "";
|
||||
Debug.Log("ATNativeAdClient : checkAdStatus....");
|
||||
try
|
||||
{
|
||||
if (nativeAdHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
adStatusJsonString = nativeAdHelperMap[placementId].Call<string>("checkAdStatus");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATNativeAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
string validAdCachesString = "";
|
||||
Debug.Log("ATNativeAdClient : getValidAdCaches....");
|
||||
try
|
||||
{
|
||||
if (nativeAdHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
validAdCachesString = nativeAdHelperMap[placementId].Call<string>("getValidAdCaches");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATNativeAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return validAdCachesString;
|
||||
}
|
||||
|
||||
public void setListener(ATNativeAdListener listener)
|
||||
{
|
||||
mlistener = listener;
|
||||
}
|
||||
|
||||
public void renderAdToScene(string placementId, ATNativeAdView anyThinkNativeAdView, string mapJson)
|
||||
{
|
||||
string showconfig = anyThinkNativeAdView.toJSON ();
|
||||
//暂未实现 show
|
||||
Debug.Log ("renderAdToScene....showconfig >>>:"+showconfig);
|
||||
try{
|
||||
if (nativeAdHelperMap.ContainsKey(placementId)) {
|
||||
nativeAdHelperMap[placementId].Call ("show",showconfig, mapJson);
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
Debug.Log ("ATNativeAdClient : error."+e.Message);
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanAdView(string placementId, ATNativeAdView anyThinkNativeAdView)
|
||||
{
|
||||
//
|
||||
Debug.Log ("cleanAdView.... ");
|
||||
try{
|
||||
|
||||
if (nativeAdHelperMap.ContainsKey(placementId)) {
|
||||
nativeAdHelperMap[placementId].Call ("cleanView");
|
||||
}
|
||||
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATNativeAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void onApplicationForces(string placementId, ATNativeAdView anyThinkNativeAdView)
|
||||
{
|
||||
|
||||
|
||||
Debug.Log ("onApplicationForces.... ");
|
||||
try{
|
||||
|
||||
if (nativeAdHelperMap.ContainsKey(placementId)) {
|
||||
nativeAdHelperMap[placementId].Call ("onResume");
|
||||
}
|
||||
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATNativeAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onApplicationPasue(string placementId, ATNativeAdView anyThinkNativeAdView)
|
||||
{
|
||||
|
||||
Debug.Log ("onApplicationPasue.... ");
|
||||
try{
|
||||
|
||||
|
||||
if (nativeAdHelperMap.ContainsKey(placementId)) {
|
||||
nativeAdHelperMap[placementId].Call ("onPause");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATNativeAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanCache(string placementId)
|
||||
{
|
||||
Debug.Log ("cleanCache....");
|
||||
try{
|
||||
if (nativeAdHelperMap.ContainsKey(placementId)) {
|
||||
nativeAdHelperMap[placementId].Call ("clean");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATNativeAdClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告展示回调
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public void onAdImpressed(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdImpressed...unity3d.");
|
||||
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告点击回调
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public void onAdClicked(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdClicked...unity3d.");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告视频开始回调
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public void onAdVideoStart(string placementId)
|
||||
{
|
||||
Debug.Log("onAdVideoStart...unity3d.");
|
||||
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告视频结束回调
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public void onAdVideoEnd(string placementId)
|
||||
{
|
||||
Debug.Log("onAdVideoEnd...unity3d.");
|
||||
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementId,""));
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告视频进度回调
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public void onAdVideoProgress(string placementId,int progress)
|
||||
{
|
||||
Debug.Log("onAdVideoProgress...progress[" + progress + "]");
|
||||
onAdVideoProgressEvent?.Invoke(this, new ATAdProgressEventArgs(placementId,"",progress));
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告视频进度回调
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public void onAdCloseButtonClicked(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdCloseButtonClicked...unity3d");
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 广告加载成功
|
||||
*/
|
||||
public void onNativeAdLoaded(string placementId)
|
||||
{
|
||||
Debug.Log("onNativeAdLoaded...unity3d.");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId,""));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告加载失败
|
||||
*/
|
||||
public void onNativeAdLoadFail(string placementId,string code, string msg)
|
||||
{
|
||||
Debug.Log("onNativeAdLoadFail...unity3d. code:" + code + " msg:" + msg);
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,code,msg));
|
||||
}
|
||||
|
||||
// Adsource Listener
|
||||
public void onAdSourceBiddingAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,callbackJson,code,error));
|
||||
}
|
||||
|
||||
public void onAdSourceAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,callbackJson,code,error));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 073dd039f9983464080e9cee9b8b81ab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
#pragma warning disable 0067
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATNativeBannerAdClient :IATNativeBannerAdClient
|
||||
{
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
public ATNativeBannerAdClient() {
|
||||
|
||||
}
|
||||
|
||||
public void loadAd(string placementId, string mapJson) {
|
||||
|
||||
}
|
||||
|
||||
public bool adReady(string placementId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setListener(ATNativeBannerAdListener listener) {
|
||||
|
||||
}
|
||||
|
||||
public void showAd(string placementId, ATRect rect, Dictionary<string, string> pairs) {
|
||||
|
||||
}
|
||||
|
||||
public void removeAd(string placementId) {
|
||||
|
||||
}
|
||||
|
||||
public void onAdLoaded(string placementId) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdLoaded()");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
}
|
||||
|
||||
public void onAdLoadFail(string placementId, string code, string message) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdLoadFail()");
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, "", code, message));
|
||||
|
||||
}
|
||||
|
||||
public void onAdImpressed(string placementId, string callbackJson) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdImpressed()");
|
||||
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
|
||||
}
|
||||
|
||||
public void onAdClicked(string placementId, string callbackJson) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdClicked()");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
public void onAdAutoRefresh(string placementId, string callbackJson) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdAutoRefresh()");
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
|
||||
}
|
||||
|
||||
public void onAdAutoRefreshFailure(string placementId, string code, string message) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdAutoRefreshFailure()");
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, "", code, message));
|
||||
|
||||
}
|
||||
|
||||
public void onAdCloseButtonClicked(string placementId) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdCloseButtonClicked()");
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc1750da0babf40ce9f9986778b3def4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AnyThinkAds.Api;
|
||||
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATNetTrafficListener : AndroidJavaProxy
|
||||
{
|
||||
ATGetUserLocationListener mListener;
|
||||
public ATNetTrafficListener(ATGetUserLocationListener listener): base("com.thinkup.unitybridge.sdkinit.SDKEUCallbackListener")
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
|
||||
public void onResultCallback(bool isEu)
|
||||
{
|
||||
if (mListener != null)
|
||||
{
|
||||
if (isEu)
|
||||
{
|
||||
mListener.didGetUserLocation(ATSDKAPI.kATUserLocationInEU);
|
||||
}
|
||||
else
|
||||
{
|
||||
mListener.didGetUserLocation(ATSDKAPI.kATUserLocationOutOfEU);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onErrorCallback(string s)
|
||||
{
|
||||
if (mListener != null)
|
||||
{
|
||||
mListener.didGetUserLocation(ATSDKAPI.kATUserLocationUnknown);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8870deba0682c40ed9c907af5aab5b96
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,416 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATRewardedVideoAdClient : AndroidJavaProxy,IATRewardedVideoAdClient
|
||||
{
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
|
||||
public event EventHandler<ATAdRewardEventArgs> onAdVideoCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onRewardEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onPlayAgainStart;
|
||||
public event EventHandler<ATAdEventArgs> onPlayAgainEnd;
|
||||
public event EventHandler<ATAdErrorEventArgs> onPlayAgainFailure;
|
||||
public event EventHandler<ATAdEventArgs> onPlayAgainClick;
|
||||
public event EventHandler<ATAdEventArgs> onPlayAgainReward;
|
||||
|
||||
|
||||
private Dictionary<string, AndroidJavaObject> videoHelperMap = new Dictionary<string, AndroidJavaObject>();
|
||||
|
||||
private AndroidJavaObject videoAutoAdHelper;
|
||||
|
||||
//private AndroidJavaObject videoHelper;
|
||||
private ATRewardedVideoListener anyThinkListener;
|
||||
|
||||
public ATRewardedVideoAdClient() : base("com.thinkup.unitybridge.videoad.VideoListener")
|
||||
{
|
||||
videoAutoAdHelper = new AndroidJavaObject("com.thinkup.unitybridge.videoad.VideoAutoAdHelper", this);
|
||||
}
|
||||
|
||||
|
||||
public void loadVideoAd(string placementId, string mapJson)
|
||||
{
|
||||
|
||||
if(!videoHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
AndroidJavaObject videoHelper = new AndroidJavaObject(
|
||||
"com.thinkup.unitybridge.videoad.VideoHelper", this);
|
||||
videoHelper.Call("initVideo", placementId);
|
||||
videoHelperMap.Add(placementId, videoHelper);
|
||||
Debug.Log("ATRewardedVideoAdClient : no exit helper ,create helper ");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Debug.Log("ATRewardedVideoAdClient : loadVideoAd ");
|
||||
videoHelperMap[placementId].Call("fillVideo", mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATRewardedVideoAdClient : error."+e.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setListener(ATRewardedVideoListener listener)
|
||||
{
|
||||
anyThinkListener = listener;
|
||||
}
|
||||
|
||||
public bool hasAdReady(string placementId)
|
||||
{
|
||||
bool isready = false;
|
||||
Debug.Log ("ATRewardedVideoAdClient : hasAdReady....");
|
||||
try{
|
||||
if (videoHelperMap.ContainsKey(placementId)) {
|
||||
isready = videoHelperMap[placementId].Call<bool> ("isAdReady");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATRewardedVideoAdClient : error."+e.Message);
|
||||
}
|
||||
return isready;
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId)
|
||||
{
|
||||
string adStatusJsonString = "";
|
||||
Debug.Log("ATRewardedVideoAdClient : checkAdStatus....");
|
||||
try
|
||||
{
|
||||
if (videoHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
adStatusJsonString = videoHelperMap[placementId].Call<string>("checkAdStatus");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATRewardedVideoAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
|
||||
Debug.Log("ATRewardedVideoAdClient : entryScenarioWithPlacementID....");
|
||||
try
|
||||
{
|
||||
if (videoHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
videoHelperMap[placementId].Call("entryAdScenario", scenarioID);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATRewardedVideoAdClient entryScenarioWithPlacementID: error." + e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
string validAdCachesString = "";
|
||||
Debug.Log("ATNativeAdClient : getValidAdCaches....");
|
||||
try
|
||||
{
|
||||
if (videoHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
validAdCachesString = videoHelperMap[placementId].Call<string>("getValidAdCaches");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATNativeAdClient : error." + e.Message);
|
||||
}
|
||||
|
||||
return validAdCachesString;
|
||||
}
|
||||
|
||||
public void showAd(string placementId, string scenario)
|
||||
{
|
||||
Debug.Log("ATRewardedVideoAdClient : showAd " );
|
||||
|
||||
try{
|
||||
if (videoHelperMap.ContainsKey(placementId)) {
|
||||
this.videoHelperMap[placementId].Call ("showVideo", scenario);
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATRewardedVideoAdClient : error."+e.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void onRewardedVideoAdLoaded(string placementId)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdLoaded...unity3d.");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
}
|
||||
|
||||
|
||||
public void onRewardedVideoAdFailed(string placementId,string code, string error)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdFailed...unity3d.");
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
|
||||
public void onRewardedVideoAdPlayStart(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdPlayStart...unity3d.");
|
||||
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
|
||||
public void onRewardedVideoAdPlayEnd(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdPlayEnd...unity3d.");
|
||||
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
|
||||
public void onRewardedVideoAdPlayFailed(string placementId,string code, string error)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdPlayFailed...unity3d.");
|
||||
onAdVideoFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
public void onRewardedVideoAdClosed(string placementId,bool isRewarded, string callbackJson)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdClosed...unity3d.");
|
||||
onAdVideoCloseEvent?.Invoke(this, new ATAdRewardEventArgs(placementId, callbackJson, isRewarded));
|
||||
}
|
||||
|
||||
public void onRewardedVideoAdPlayClicked(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdPlayClicked...unity3d.");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void onReward(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onReward...unity3d.");
|
||||
onRewardEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
|
||||
public void onRewardedVideoAdAgainPlayStart(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdAgainPlayStart...unity3d.");
|
||||
onPlayAgainStart?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onRewardedVideoAdAgainPlayEnd(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdAgainPlayEnd...unity3d.");
|
||||
onPlayAgainEnd?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
|
||||
public void onRewardedVideoAdAgainPlayFailed(string placementId, string code, string error)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdAgainPlayFailed...unity3d.");
|
||||
onPlayAgainFailure?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
|
||||
public void onRewardedVideoAdAgainPlayClicked(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onRewardedVideoAdAgainPlayClicked...unity3d.");
|
||||
onPlayAgainClick?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void onAgainReward(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAgainReward...unity3d.");
|
||||
onPlayAgainReward?.Invoke(this, new ATAdRewardEventArgs(placementId, callbackJson, true));
|
||||
}
|
||||
|
||||
// Adsource Listener
|
||||
public void onAdSourceBiddingAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingAttempt...unity3d."+ placementId + "," + callbackJson);
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFilled...unity3d." + placementId + "," + callbackJson);
|
||||
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceBiddingFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
public void onAdSourceAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFilled(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFilled...unity3d." + placementId + "," + callbackJson);
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("onAdSourceLoadFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
onAdSourceLoadFailureEvent?.Invoke(this,new ATAdErrorEventArgs(placementId, code, error));
|
||||
}
|
||||
|
||||
|
||||
// Auto
|
||||
public void addAutoLoadAdPlacementID(string[] placementIDList){
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:addAutoLoadAdPlacementID()" + JsonMapper.ToJson(placementIDList));
|
||||
try
|
||||
{
|
||||
videoAutoAdHelper.Call("addPlacementIds", JsonMapper.ToJson(placementIDList));
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient addAutoLoadAdPlacementID: error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAutoLoadAdPlacementID(string placementId) {
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:removeAutoLoadAdPlacementID()");
|
||||
try
|
||||
{
|
||||
videoAutoAdHelper.Call("removePlacementIds", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient removeAutoLoadAdPlacementID: error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public bool autoLoadRewardedVideoReadyForPlacementID(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:autoLoadRewardedVideoReadyForPlacementID()");
|
||||
bool isready = false;
|
||||
try
|
||||
{
|
||||
isready = videoAutoAdHelper.Call<bool>("isAdReady", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATRewardedVideoAdClient:autoLoadRewardedVideoReadyForPlacementID( : error." + e.Message);
|
||||
}
|
||||
return isready;
|
||||
}
|
||||
|
||||
public string getAutoValidAdCaches(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:getAutoValidAdCaches()");
|
||||
string adStatusJsonString = "";
|
||||
try
|
||||
{
|
||||
adStatusJsonString = videoAutoAdHelper.Call<string>("getValidAdCaches", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATRewardedVideoAdClient:getAutoValidAdCaches() : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
public void setAutoLocalExtra(string placementId, string mapJson)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:setAutoLocalExtra()");
|
||||
try
|
||||
{
|
||||
videoAutoAdHelper.Call("setAdExtraData", placementId, mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATRewardedVideoAdClient:setAutoLocalExtra() : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:entryAutoAdScenarioWithPlacementID()");
|
||||
try
|
||||
{
|
||||
videoAutoAdHelper.Call("entryAdScenario", placementId, scenarioID);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATRewardedVideoAdClient:entryAutoAdScenarioWithPlacementID() : error." + e.Message);
|
||||
}
|
||||
}
|
||||
public void showAutoAd(string placementId, string mapJson) {
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:showAutoAd()");
|
||||
try
|
||||
{
|
||||
videoAutoAdHelper.Call("show", placementId, mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:showAutoAd() : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public string checkAutoAdStatus(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:checkAutoAdStatus() : checkAutoAdStatus....");
|
||||
string adStatusJsonString = "";
|
||||
try
|
||||
{
|
||||
adStatusJsonString = videoAutoAdHelper.Call<string>("checkAdStatus", placementId);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("Unity: ATRewardedVideoAdClient:checkAutoAdStatus() : error." + e.Message);
|
||||
}
|
||||
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b67705314096943b09a0f14eafff6a62
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,394 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATSDKAPIClient : AndroidJavaProxy, IATSDKAPIClient
|
||||
{
|
||||
private AndroidJavaObject sdkInitHelper;
|
||||
private ATSDKInitListener sdkInitListener;
|
||||
public ATSDKAPIClient () : base("com.thinkup.unitybridge.sdkinit.SDKInitListener")
|
||||
{
|
||||
this.sdkInitHelper = new AndroidJavaObject(
|
||||
"com.thinkup.unitybridge.sdkinit.SDKInitHelper", this);
|
||||
}
|
||||
|
||||
public void initSDK(string appId, string appKey)
|
||||
{
|
||||
this.initSDK(appId, appKey, null);
|
||||
}
|
||||
|
||||
public void initSDK(string appId, string appKey, ATSDKInitListener listener)
|
||||
{
|
||||
Debug.Log("initSDK....");
|
||||
sdkInitListener = listener;
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("initAppliction", appId, appKey);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATSDKAPIClient : error."+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void getUserLocation(ATGetUserLocationListener listener)
|
||||
{
|
||||
ATNetTrafficListener netTrafficListener = new ATNetTrafficListener(listener);
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("checkIsEuTraffic", netTrafficListener);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
//implement getting location here
|
||||
}
|
||||
|
||||
public void setGDPRLevel(int level)
|
||||
{
|
||||
Debug.Log ("setGDPRLevel....");
|
||||
try{
|
||||
if (this.sdkInitHelper != null) {
|
||||
this.sdkInitHelper.Call ("setGDPRLevel",level);
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATSDKAPIClient : error."+e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void showGDPRAuth()
|
||||
{
|
||||
Debug.Log ("showGDPRAuth....");
|
||||
try{
|
||||
if (this.sdkInitHelper != null) {
|
||||
this.sdkInitHelper.Call ("showGDPRAuth");
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATSDKAPIClient : error."+e.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void showGDPRConsentDialog(ATConsentDismissListener listener)
|
||||
{
|
||||
Debug.Log ("showGDPRConsentDialog....");
|
||||
ATGDPRConsentDismissListener gdprConsentDismissListener = new ATGDPRConsentDismissListener(listener);
|
||||
try{
|
||||
if (this.sdkInitHelper != null) {
|
||||
this.sdkInitHelper.Call ("showGDPRConsentDialog", gdprConsentDismissListener);
|
||||
}
|
||||
}catch(System.Exception e){
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log ("ATSDKAPIClient : error."+e.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void setChannel(string channel)
|
||||
{
|
||||
Debug.Log("setChannel....");
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("setChannel", channel);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSubChannel(string subchannel)
|
||||
{
|
||||
Debug.Log("setSubChannel....");
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("setSubChannel", subchannel);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void initCustomMap(string jsonMap)
|
||||
{
|
||||
Debug.Log("initCustomMap....");
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("initCustomMap", jsonMap);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCustomDataForPlacementID(string customData, string placementID)
|
||||
{
|
||||
Debug.Log("setCustomDataForPlacementID....");
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("initPlacementCustomMap", placementID, customData);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLogDebug(bool isDebug)
|
||||
{
|
||||
Debug.Log("setLogDebug....");
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("setDebugLogOpen", isDebug);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void addNetworkGDPRInfo(int networkType, string mapJson)
|
||||
{
|
||||
// Debug.Log ("addNetworkGDPRInfo...." + networkType + "mapjson:"+mapJson);
|
||||
// try{
|
||||
// if (this.sdkInitHelper != null) {
|
||||
// this.sdkInitHelper.Call ("addNetworkGDPRInfo",networkType,mapJson);
|
||||
// }
|
||||
// }catch(System.Exception e){
|
||||
// System.Console.WriteLine("Exception caught: {0}", e);
|
||||
// Debug.Log ("ATSDKAPIClient : error."+e.Message);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
public void initSDKSuccess(string appid)
|
||||
{
|
||||
Debug.Log("initSDKSuccess...unity3d.");
|
||||
if(sdkInitListener != null){
|
||||
sdkInitListener.initSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
public void initSDKError(string appid, string message)
|
||||
{
|
||||
Debug.Log("initSDKError..unity3d..");
|
||||
if (sdkInitListener != null)
|
||||
{
|
||||
sdkInitListener.initFail(message);
|
||||
}
|
||||
}
|
||||
|
||||
public int getGDPRLevel()
|
||||
{
|
||||
Debug.Log("getGDPRLevel....");
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
return this.sdkInitHelper.Call<int>("getGDPRLevel");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
return 2; //UNKNOW
|
||||
}
|
||||
|
||||
public bool isEUTraffic()
|
||||
{
|
||||
Debug.Log("isEUTraffic....");
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
return this.sdkInitHelper.Call<bool>("isEUTraffic");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void deniedUploadDeviceInfo(string deniedInfoString)
|
||||
{
|
||||
Debug.Log("deniedUploadDeviceInfo....");
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("deniedUploadDeviceInfo", deniedInfoString);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void setExcludeBundleIdArray(string bundleIds)
|
||||
{
|
||||
Debug.Log("setExcludeBundleIdArray....");
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("setExcludeBundleIdArray", bundleIds);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void setExcludeAdSourceIdArrayForPlacementID(string placementID, string adsourceIds)
|
||||
{
|
||||
Debug.Log("setExcludeAdSourceIdArrayForPlacementID....");
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("setExcludeAdSourceIdArrayForPlacementID", placementID, adsourceIds);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSDKArea(int area)
|
||||
{
|
||||
Debug.Log("setSDKArea....");
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("setSDKArea", area);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void getArea(ATGetAreaListener listener)
|
||||
{
|
||||
Debug.Log("getArea....");
|
||||
ATAreaListener areaListener = new ATAreaListener(listener);
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("getArea", areaListener);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void setWXStatus(bool install)
|
||||
{
|
||||
Debug.Log("setWXStatus....");
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("setWXStatus", install);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLocation(double longitude, double latitude)
|
||||
{
|
||||
Debug.Log("setLocation....");
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("setLocation", longitude, latitude);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void showDebuggerUI() {
|
||||
showDebuggerUI("");
|
||||
}
|
||||
|
||||
public void showDebuggerUI(string debugKey) {
|
||||
try
|
||||
{
|
||||
if (this.sdkInitHelper != null)
|
||||
{
|
||||
this.sdkInitHelper.Call("showDebuggerUI", debugKey);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
System.Console.WriteLine("Exception caught: {0}", e);
|
||||
Debug.Log("ATSDKAPIClient : error." + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff0227a36885e478ea01e4084ba344d7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,237 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
|
||||
namespace AnyThinkAds.Android
|
||||
{
|
||||
public class ATSplashAdClient : AndroidJavaProxy, IATSplashAdClient
|
||||
{
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadTimeoutEvent;
|
||||
public event EventHandler<ATAdEventArgs> onDeeplinkEvent;
|
||||
public event EventHandler<ATAdEventArgs> onDownloadConfirmEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdShowEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdShowFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
|
||||
private Dictionary<string, AndroidJavaObject> splashHelperMap = new Dictionary<string, AndroidJavaObject>();
|
||||
private ATSplashAdListener splashAdListener;
|
||||
|
||||
private int fetchAdTimeout = 0;
|
||||
private string defaultAdSourceConfig;
|
||||
|
||||
public ATSplashAdClient() : base("com.thinkup.unitybridge.splash.SplashListener")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private AndroidJavaObject getSplashHelper(string placementId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!splashHelperMap.ContainsKey(placementId))
|
||||
{
|
||||
AndroidJavaObject splashHelper = new AndroidJavaObject(
|
||||
"com.thinkup.unitybridge.splash.SplashHelper", this);
|
||||
splashHelper.Call("initSplash", placementId, fetchAdTimeout, defaultAdSourceConfig);
|
||||
splashHelperMap.Add(placementId, splashHelper);
|
||||
return splashHelper;
|
||||
} else {
|
||||
return splashHelperMap[placementId];
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
ATLogger.LogError("getSplashHelper() >>> error: {0}", e.Message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void loadSplashAd(string placementId, int fetchAdTimeout = 0, string defaultAdSourceConfig = "", string mapJson = "")
|
||||
{
|
||||
this.fetchAdTimeout = fetchAdTimeout;
|
||||
this.defaultAdSourceConfig = defaultAdSourceConfig;
|
||||
try
|
||||
{
|
||||
ATLogger.Log("loadSplashAd() >>> placementId: {0}", placementId);
|
||||
getSplashHelper(placementId).Call("loadAd", mapJson);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
ATLogger.LogError("loadSplashAd() >>> error: {0}", e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener(ATSplashAdListener listener)
|
||||
{
|
||||
this.splashAdListener = listener;
|
||||
}
|
||||
|
||||
public bool hasSplashAdReady(string placementId)
|
||||
{
|
||||
bool isAdReady = false;
|
||||
ATLogger.Log("hasSplashAdReady() >>> placementId: {0}", placementId);
|
||||
try
|
||||
{
|
||||
isAdReady = getSplashHelper(placementId).Call<bool>("isAdReady");
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
ATLogger.LogError("hasSplashAdReady() >>> error: {0}", e.Message);
|
||||
}
|
||||
return isAdReady;
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId)
|
||||
{
|
||||
string adStatusJsonString = "";
|
||||
ATLogger.Log("checkAdStatus() >>> placementId: {0}", placementId);
|
||||
try
|
||||
{
|
||||
adStatusJsonString = getSplashHelper(placementId).Call<string>("checkAdStatus");
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
ATLogger.LogError("checkAdStatus() >>> error: {0}", e.Message);
|
||||
}
|
||||
return adStatusJsonString;
|
||||
}
|
||||
|
||||
public void showSplashAd(string placementId, string mapJson)
|
||||
{
|
||||
ATLogger.Log("showSplashAd() >>> placementId: {0}, mapJson: {1}", placementId, mapJson);
|
||||
try
|
||||
{
|
||||
getSplashHelper(placementId).Call("showAd", mapJson);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
ATLogger.LogError("showSplashAd() >>> error: {0}", e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
ATLogger.Log("getValidAdCaches() >>> placementId: {0}", placementId);
|
||||
string adString = "";
|
||||
try
|
||||
{
|
||||
adString = getSplashHelper(placementId).Call<string>("getValidAdCaches");
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
ATLogger.LogError("getValidAdCaches() >>> error: {0}", e.Message);
|
||||
}
|
||||
return adString;
|
||||
}
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID)
|
||||
{
|
||||
ATLogger.Log("entryScenarioWithPlacementID() >>> placementId: {0}, scenarioID: {1}", placementId, scenarioID);
|
||||
|
||||
try
|
||||
{
|
||||
getSplashHelper(placementId).Call<string>("entryAdScenario", scenarioID);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
ATLogger.LogError("entryScenarioWithPlacementID() >>> error: {0}", e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void onSplashAdLoad(String unitId, bool isTimeout)
|
||||
{
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(unitId, "", isTimeout));
|
||||
}
|
||||
|
||||
public void onSplashAdLoadTimeOut(String unitId)
|
||||
{
|
||||
onAdLoadTimeoutEvent?.Invoke(this, new ATAdEventArgs(unitId, "", true));
|
||||
}
|
||||
|
||||
public void onSplashAdLoadFailed(String unitId, String code, String msg)
|
||||
{
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(unitId, code, msg));
|
||||
}
|
||||
|
||||
public void onSplashAdShow(String unitId, String callbackJson)
|
||||
{
|
||||
onAdShowEvent?.Invoke(this, new ATAdEventArgs(unitId, callbackJson));
|
||||
}
|
||||
|
||||
public void onSplashAdClick(String unitId, String callbackJson)
|
||||
{
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(unitId, callbackJson));
|
||||
}
|
||||
|
||||
public void onSplashAdDismiss(String unitId, String callbackJson)
|
||||
{
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(unitId, callbackJson));
|
||||
}
|
||||
|
||||
public void onSplashAdDeeplinkCallback(String unitId, String callbackJson, bool isSuccess)
|
||||
{
|
||||
onDeeplinkEvent?.Invoke(this, new ATAdEventArgs(unitId, callbackJson, false, isSuccess));
|
||||
}
|
||||
|
||||
public void onSplashAdDownloadConfirm(String unitId, String callbackJson)
|
||||
{
|
||||
onDownloadConfirmEvent?.Invoke(this, new ATAdEventArgs(unitId, callbackJson));
|
||||
}
|
||||
|
||||
// Adsource Listener
|
||||
public void onAdSourceBiddingAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
ATLogger.Log("onAdSourceBiddingAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFilled(string placementId, string callbackJson)
|
||||
{
|
||||
ATLogger.Log("onAdSourceBiddingFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceBiddingFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
ATLogger.Log("onAdSourceBiddingFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
|
||||
public void onAdSourceAttempt(string placementId, string callbackJson)
|
||||
{
|
||||
ATLogger.Log("onAdSourceAttempt...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFilled(string placementId, string callbackJson)
|
||||
{
|
||||
ATLogger.Log("onAdSourceLoadFilled...unity3d." + placementId + "," + callbackJson);
|
||||
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void onAdSourceLoadFail(string placementId, string callbackJson, string code, string error)
|
||||
{
|
||||
ATLogger.Log("onAdSourceLoadFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
|
||||
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4263f047452042a1ae0319969384830
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b2e16073d63e4d5188cb6e223698c73
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,171 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
using System;
|
||||
|
||||
namespace AnyThinkAds.iOS {
|
||||
public class ATBannerAdClient : IATBannerAdClient {
|
||||
|
||||
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdAutoRefreshEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdAutoRefreshFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseButtonTappedEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
|
||||
private ATBannerAdListener anyThinkListener;
|
||||
|
||||
|
||||
public void addsetting(string placementId,string json){
|
||||
//todo...
|
||||
}
|
||||
|
||||
public void setListener(ATBannerAdListener listener) {
|
||||
Debug.Log("Unity: ATBannerAdClient::setListener()");
|
||||
anyThinkListener = listener;
|
||||
}
|
||||
|
||||
public void loadBannerAd(string placementId, string mapJson) {
|
||||
Debug.Log("Unity: ATBannerAdClient::loadBannerAd()");
|
||||
ATBannerAdWrapper.setClientForPlacementID(placementId, this);
|
||||
ATBannerAdWrapper.loadBannerAd(placementId, mapJson);
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId) {
|
||||
Debug.Log("Unity: ATBannerAdClient::checkAdStatus()");
|
||||
return ATBannerAdWrapper.checkAdStatus(placementId);
|
||||
}
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATBannerAdClient::getValidAdCaches()");
|
||||
return ATBannerAdWrapper.getValidAdCaches(placementId);
|
||||
}
|
||||
|
||||
public void showBannerAd(string placementId, ATRect rect) {
|
||||
Debug.Log("Unity: ATBannerAdClient::showBannerAd()");
|
||||
ATBannerAdWrapper.showBannerAd(placementId, rect);
|
||||
}
|
||||
|
||||
public void showBannerAd(string placementId, ATRect rect, string mapJson) {
|
||||
Debug.Log("Unity: ATBannerAdClient::showBannerAd()");
|
||||
ATBannerAdWrapper.showBannerAd(placementId, rect, mapJson);
|
||||
}
|
||||
|
||||
public void showBannerAd(string placementId, string position)
|
||||
{
|
||||
Debug.Log("Unity: ATBannerAdClient::showBannerAd()");
|
||||
ATBannerAdWrapper.showBannerAd(placementId, position);
|
||||
}
|
||||
|
||||
public void showBannerAd(string placementId, string position, string mapJson)
|
||||
{
|
||||
Debug.Log("Unity: ATBannerAdClient::showBannerAd()");
|
||||
ATBannerAdWrapper.showBannerAd(placementId, position, mapJson);
|
||||
}
|
||||
|
||||
public void cleanBannerAd(string placementId) {
|
||||
Debug.Log("Unity: ATBannerAdClient::cleanBannerAd()");
|
||||
ATBannerAdWrapper.cleanBannerAd(placementId);
|
||||
}
|
||||
|
||||
public void hideBannerAd(string placementId) {
|
||||
Debug.Log("Unity: ATBannerAdClient::hideBannerAd()");
|
||||
ATBannerAdWrapper.hideBannerAd(placementId);
|
||||
}
|
||||
|
||||
public void showBannerAd(string placementId) {
|
||||
Debug.Log("Unity: ATBannerAdClient::showBannerAd()");
|
||||
ATBannerAdWrapper.showBannerAd(placementId);
|
||||
}
|
||||
|
||||
public void cleanCache(string placementId) {
|
||||
Debug.Log("Unity: ATBannerAdClient::cleanCache()");
|
||||
ATBannerAdWrapper.clearCache();
|
||||
}
|
||||
|
||||
|
||||
public void OnBannerAdLoad(string placementId) {
|
||||
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdLoad()");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
}
|
||||
|
||||
public void OnBannerAdLoadFail(string placementId, string code, string message) {
|
||||
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdLoadFail()");
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, message));
|
||||
}
|
||||
|
||||
public void OnBannerAdImpress(string placementId, string callbackJson) {
|
||||
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdImpress()");
|
||||
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void OnBannerAdClick(string placementId, string callbackJson) {
|
||||
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdClick()");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void OnBannerAdAutoRefresh(string placementId, string callbackJson) {
|
||||
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdAutoRefresh()");
|
||||
onAdAutoRefreshEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
|
||||
public void OnBannerAdAutoRefreshFail(string placementId, string code, string message) {
|
||||
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdAutoRefreshFail()");
|
||||
onAdAutoRefreshFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, code, message));
|
||||
}
|
||||
|
||||
public void OnBannerAdClose(string placementId) {
|
||||
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdClose()");
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
}
|
||||
|
||||
public void OnBannerAdCloseButtonTapped(string placementId, string callbackJson) {
|
||||
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdCloseButton()");
|
||||
onAdCloseButtonTappedEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
//auto callbacks
|
||||
public void startLoadingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: HBBannerAdWrapper::startLoadingADSource()");
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void finishLoadingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: HBBannerAdWrapper::finishLoadingADSource()");
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void failToLoadADSource(string placementId,string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("Unity: HBBannerAdWrapper::failToLoadADSource()");
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
public void startBiddingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: HBBannerAdWrapper::startBiddingADSource()");
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void finishBiddingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: HBBannerAdWrapper::finishBiddingADSource()");
|
||||
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void failBiddingADSource(string placementId, string callbackJson,string code, string error)
|
||||
{
|
||||
Debug.Log("Unity: HBBannerAdWrapper::failBiddingADSource()");
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 954a7ddf44b474445bf858fc53ee63fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,221 @@
|
||||
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 ATInterstitialAdClient : IATInterstitialAdClient {
|
||||
private ATInterstitialAdListener anyThinkListener;
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdShowEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdShowFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
|
||||
public void addsetting(string placementId,string json){
|
||||
//todo...
|
||||
}
|
||||
|
||||
public void setListener(ATInterstitialAdListener listener) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::setListener()");
|
||||
anyThinkListener = listener;
|
||||
}
|
||||
|
||||
public void loadInterstitialAd(string placementId, string mapJson) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::loadInterstitialAd()");
|
||||
ATInterstitialAdWrapper.setClientForPlacementID(placementId, this);
|
||||
ATInterstitialAdWrapper.loadInterstitialAd(placementId, mapJson);
|
||||
}
|
||||
|
||||
public bool hasInterstitialAdReady(string placementId) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::hasInterstitialAdReady()");
|
||||
return ATInterstitialAdWrapper.hasInterstitialAdReady(placementId);
|
||||
}
|
||||
|
||||
public void showInterstitialAd(string placementId, string mapJson) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::showInterstitialAd()");
|
||||
ATInterstitialAdWrapper.showInterstitialAd(placementId, mapJson);
|
||||
}
|
||||
|
||||
public void cleanCache(string placementId) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::cleanCache()");
|
||||
ATInterstitialAdWrapper.clearCache(placementId);
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::checkAdStatus()");
|
||||
return ATInterstitialAdWrapper.checkAdStatus(placementId);
|
||||
}
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient::getValidAdCaches()");
|
||||
return ATInterstitialAdWrapper.getValidAdCaches(placementId);
|
||||
}
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
|
||||
Debug.Log("Unity: ATInterstitialAdClient::entryScenarioWithPlacementID()");
|
||||
ATInterstitialAdWrapper.entryScenarioWithPlacementID(placementId,scenarioID);
|
||||
}
|
||||
|
||||
|
||||
//Callbacks
|
||||
public void OnInterstitialAdLoaded(string placementID) {
|
||||
Debug.Log("onInterstitialAdLoaded...unity3d.");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementID));
|
||||
}
|
||||
|
||||
public void OnInterstitialAdLoadFailure(string placementID, string code, string error) {
|
||||
Debug.Log("onInterstitialAdFailed...unity3d.");
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, code, error));
|
||||
}
|
||||
|
||||
public void OnInterstitialAdVideoPlayFailure(string placementID, string code, string error) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdVideoPlayFailure()");
|
||||
onAdVideoFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, code, error));
|
||||
}
|
||||
|
||||
public void OnInterstitialAdVideoPlayStart(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdPlayStart()");
|
||||
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
public void OnInterstitialAdVideoPlayEnd(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdVideoPlayEnd()");
|
||||
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
public void OnInterstitialAdShow(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdShow()");
|
||||
onAdShowEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
public void OnInterstitialAdFailedToShow(string placementID) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdFailedToShow()");
|
||||
onAdShowFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, "-1", "Failed to show video ad"));
|
||||
}
|
||||
|
||||
public void OnInterstitialAdClick(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdClick()");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
public void OnInterstitialAdClose(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdClose()");
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
//auto callbacks
|
||||
public void startLoadingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient::startLoadingADSource()");
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void finishLoadingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient::finishLoadingADSource()");
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void failToLoadADSource(string placementId, string callbackJson,string code, string error)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient::failToLoadADSource()");
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
public void startBiddingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient::startBiddingADSource()");
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void finishBiddingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient::finishBiddingADSource()");
|
||||
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void failBiddingADSource(string placementId,string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient::failBiddingADSource()");
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
|
||||
// Auto
|
||||
public void addAutoLoadAdPlacementID(string[] placementIDList)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:addAutoLoadAdPlacementID()");
|
||||
|
||||
|
||||
|
||||
if (placementIDList != null && placementIDList.Length > 0)
|
||||
{
|
||||
foreach (string placementID in placementIDList)
|
||||
{
|
||||
ATInterstitialAdWrapper.setClientForPlacementID(placementID, this);
|
||||
}
|
||||
|
||||
string placementIDListString = JsonMapper.ToJson(placementIDList);
|
||||
ATInterstitialAdWrapper.addAutoLoadAdPlacementID(placementIDListString);
|
||||
Debug.Log("addAutoLoadAdPlacementID, placementIDList === " + placementIDListString);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("addAutoLoadAdPlacementID, placementIDList = null");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void removeAutoLoadAdPlacementID(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:removeAutoLoadAdPlacementID()");
|
||||
ATInterstitialAdWrapper.removeAutoLoadAdPlacementID(placementId);
|
||||
}
|
||||
|
||||
public bool autoLoadInterstitialAdReadyForPlacementID(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:autoLoadInterstitialAdReadyForPlacementID()");
|
||||
return ATInterstitialAdWrapper.autoLoadInterstitialAdReadyForPlacementID(placementId);
|
||||
}
|
||||
public string getAutoValidAdCaches(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:getAutoValidAdCaches()");
|
||||
return ATInterstitialAdWrapper.getAutoValidAdCaches(placementId);
|
||||
}
|
||||
|
||||
public string checkAutoAdStatus(string placementId) {
|
||||
Debug.Log("Unity: ATInterstitialAdClient::checkAutoAdStatus()");
|
||||
return ATInterstitialAdWrapper.checkAutoAdStatus(placementId);
|
||||
}
|
||||
|
||||
|
||||
public void setAutoLocalExtra(string placementId, string mapJson)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:setAutoLocalExtra()");
|
||||
ATInterstitialAdWrapper.setAutoLocalExtra(placementId, mapJson);
|
||||
}
|
||||
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient:entryAutoAdScenarioWithPlacementID()");
|
||||
ATInterstitialAdWrapper.entryAutoAdScenarioWithPlacementID(placementId, scenarioID);
|
||||
}
|
||||
public void showAutoAd(string placementId, string mapJson)
|
||||
{
|
||||
Debug.Log("Unity: ATInterstitialAdClient::showAutoAd()");
|
||||
ATInterstitialAdWrapper.showAutoInterstitialAd(placementId, mapJson);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 950c39b6d4dc7469da41ca3af9d9bb5e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,182 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
using AnyThinkAds.iOS;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
#pragma warning disable 0067
|
||||
namespace AnyThinkAds.iOS {
|
||||
public class ATNativeAdClient : IATNativeAdClient {
|
||||
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
|
||||
private ATNativeAdListener mlistener;
|
||||
public void loadNativeAd(string placementId, string mapJson) {
|
||||
Debug.Log("Unity:ATNativeAdClient::loadNativeAd()");
|
||||
ATNativeAdWrapper.setClientForPlacementID(placementId, this);
|
||||
ATNativeAdWrapper.loadNativeAd(placementId, mapJson);
|
||||
}
|
||||
|
||||
public void setLocalExtra (string placementId,string localExtra){
|
||||
|
||||
}
|
||||
|
||||
public bool hasAdReady(string placementId) {
|
||||
Debug.Log("Unity:ATNativeAdClient::hasAdReady()");
|
||||
return ATNativeAdWrapper.isNativeAdReady(placementId);
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId) {
|
||||
Debug.Log("Unity: ATNativeAdClient::checkAdStatus()");
|
||||
return ATNativeAdWrapper.checkAdStatus(placementId);
|
||||
}
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
|
||||
|
||||
Debug.Log("Unity: ATNativeAdClient::entryScenarioWithPlacementID()");
|
||||
ATNativeAdWrapper.entryScenarioWithPlacementID(placementId,scenarioID);
|
||||
}
|
||||
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdClient::getValidAdCaches()");
|
||||
return ATNativeAdWrapper.getValidAdCaches(placementId);
|
||||
}
|
||||
|
||||
public void setListener(ATNativeAdListener listener) {
|
||||
Debug.Log("Unity:ATNativeAdClient::setListener()");
|
||||
mlistener = listener;
|
||||
}
|
||||
|
||||
public void renderAdToScene(string placementId, ATNativeAdView anyThinkNativeAdView) {
|
||||
Debug.Log("Unity:ATNativeAdClient::renderAdToScene()");
|
||||
ATNativeAdWrapper.showNativeAd(placementId, anyThinkNativeAdView.toJSON());
|
||||
}
|
||||
|
||||
public void renderAdToScene(string placementId, ATNativeAdView anyThinkNativeAdView, string mapJson) {
|
||||
Debug.Log("Unity:ATNativeAdClient::renderAdToScene()");
|
||||
ATNativeAdWrapper.showNativeAd(placementId, anyThinkNativeAdView.toJSON(), mapJson);
|
||||
}
|
||||
|
||||
public void cleanAdView(string placementId, ATNativeAdView anyThinkNativeAdView) {
|
||||
Debug.Log("Unity:ATNativeAdClient::cleanAdView()");
|
||||
ATNativeAdWrapper.removeNativeAdView(placementId);
|
||||
}
|
||||
|
||||
public void onApplicationForces(string placementId, ATNativeAdView anyThinkNativeAdView) {
|
||||
Debug.Log("Unity:ATNativeAdClient::onApplicationForces()");
|
||||
}
|
||||
|
||||
public void onApplicationPasue(string placementId, ATNativeAdView anyThinkNativeAdView) {
|
||||
Debug.Log("Unity:ATNativeAdClient::onApplicationPasue()");
|
||||
}
|
||||
|
||||
public void cleanCache(string placementId) {
|
||||
Debug.Log("Unity:ATNativeAdClient::cleanCache()");
|
||||
ATNativeAdWrapper.clearCache();
|
||||
}
|
||||
|
||||
//Callbacks
|
||||
public void onAdImpressed(string placementId, string callbackJson) {
|
||||
Debug.Log("Unity:ATNativeAdClient::onAdImpressed...unity3d.");
|
||||
|
||||
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
|
||||
}
|
||||
|
||||
public void onAdClicked(string placementId, string callbackJson) {
|
||||
Debug.Log("Unity:ATNativeAdClient::onAdClicked...unity3d.");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
|
||||
}
|
||||
|
||||
public void onAdCloseButtonClicked(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity:ATNativeAdClient::onAdCloseButtonClicked...unity3d.");
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
|
||||
}
|
||||
|
||||
public void onAdVideoStart(string placementId) {
|
||||
Debug.Log("Unity:ATNativeAdClient::onAdVideoStart...unity3d.");
|
||||
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
|
||||
}
|
||||
|
||||
public void onAdVideoEnd(string placementId) {
|
||||
Debug.Log("Unity:ATNativeAdClient::onAdVideoEnd...unity3d.");
|
||||
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementId,""));
|
||||
}
|
||||
|
||||
public void onAdVideoProgress(string placementId,int progress) {
|
||||
Debug.Log("Unity:ATNativeAdClient::onAdVideoProgress...progress[" + progress + "]");
|
||||
onAdVideoProgressEvent?.Invoke(this, new ATAdProgressEventArgs(placementId,"",progress));
|
||||
}
|
||||
|
||||
public void onNativeAdLoaded(string placementId) {
|
||||
Debug.Log("Unity:ATNativeAdClient::onNativeAdLoaded...unity3d.");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId,""));
|
||||
|
||||
}
|
||||
|
||||
public void onNativeAdLoadFail(string placementId,string code, string msg) {
|
||||
Debug.Log("Unity:ATNativeAdClient::onNativeAdLoadFail...unity3d. code:" + code + " msg:" + msg);
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,code,msg));
|
||||
}
|
||||
|
||||
//auto callbacks
|
||||
public void startLoadingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdClient::startLoadingADSource()");
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
public void finishLoadingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdClient::finishLoadingADSource()");
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
|
||||
}
|
||||
public void failToLoadADSource(string placementId,string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdClient::failToLoadADSource()");
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,code,error));
|
||||
|
||||
}
|
||||
public void startBiddingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdClient::startBiddingADSource()");
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
|
||||
}
|
||||
public void finishBiddingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdClient::finishBiddingADSource()");
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
|
||||
}
|
||||
|
||||
public void failBiddingADSource(string placementId,string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("Unity: ATNativeAdClient::failBiddingADSource()");
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,callbackJson,code,error));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: adbfdd1abf5ca4e94b94f108d645ed66
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
#pragma warning disable 0067
|
||||
namespace AnyThinkAds.iOS
|
||||
{
|
||||
public class ATNativeBannerAdClient : IATNativeBannerAdClient
|
||||
{
|
||||
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
private ATNativeBannerAdListener listener;
|
||||
public void loadAd(string placementId, string mapJson) {
|
||||
Debug.Log("ATNativeBannerAdClient::loadAd()");
|
||||
ATNativeBannerAdWrapper.setClientForPlacementID(placementId, this);
|
||||
Debug.Log("ATNativeBannerAdClient::loadAd(), after set client");
|
||||
ATNativeBannerAdWrapper.loadAd(placementId, mapJson);
|
||||
Debug.Log("ATNativeBannerAdClient::loadAd(), after invoke load ad");
|
||||
}
|
||||
|
||||
public bool adReady(string placementId) {
|
||||
Debug.Log("ATNativeBannerAdClient::adReady()");
|
||||
return ATNativeBannerAdWrapper.adReady(placementId);
|
||||
}
|
||||
|
||||
public void setListener(ATNativeBannerAdListener listener) {
|
||||
Debug.Log("ATNativeBannerAdClient::setListener()");
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void showAd(string placementId, ATRect rect, Dictionary<string, string> pairs) {
|
||||
Debug.Log("ATNativeBannerAdClient::showAd()");
|
||||
ATNativeBannerAdWrapper.showAd(placementId, rect, pairs);
|
||||
}
|
||||
|
||||
public void removeAd(string placementId) {
|
||||
Debug.Log("ATNativeBannerAdClient::removeAd()");
|
||||
ATNativeBannerAdWrapper.removeAd(placementId);
|
||||
}
|
||||
|
||||
//Listener method(s)
|
||||
public void onAdLoaded(string placementId) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdLoaded()");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
}
|
||||
|
||||
public void onAdLoadFail(string placementId, string code, string message) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdLoadFail()");
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, "", code, message));
|
||||
|
||||
}
|
||||
|
||||
public void onAdImpressed(string placementId, string callbackJson) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdImpressed()");
|
||||
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
|
||||
}
|
||||
|
||||
public void onAdClicked(string placementId, string callbackJson) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdClicked()");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
}
|
||||
|
||||
public void onAdAutoRefresh(string placementId, string callbackJson) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdAutoRefresh()");
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
|
||||
|
||||
}
|
||||
|
||||
public void onAdAutoRefreshFailure(string placementId, string code, string message) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdAutoRefreshFailure()");
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, "", code, message));
|
||||
|
||||
}
|
||||
|
||||
public void onAdCloseButtonClicked(string placementId) {
|
||||
Debug.Log("ATNativeBannerAdClient::onAdCloseButtonClicked()");
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d7cc19b4b7cf4a57b79dabdbdb94d2c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,259 @@
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b30dac781c4344df9754e38cf6472cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,210 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
using AOT;
|
||||
using System;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
|
||||
namespace AnyThinkAds.iOS {
|
||||
public class ATSDKAPIClient : IATSDKAPIClient {
|
||||
static private ATGetUserLocationListener locationListener;
|
||||
static private ATGetAreaListener areaListener;
|
||||
|
||||
static private ATConsentDismissListener umpListener;
|
||||
|
||||
public ATSDKAPIClient () {
|
||||
Debug.Log("Unity:ATSDKAPIClient::ATSDKAPIClient()");
|
||||
}
|
||||
public void initSDK(string appId, string appKey) {
|
||||
Debug.Log("Unity:ATSDKAPIClient::initSDK(string, string)");
|
||||
initSDK(appId, appKey, null);
|
||||
}
|
||||
|
||||
public void initSDK(string appId, string appKey, ATSDKInitListener listener) {
|
||||
Debug.Log("Unity:ATSDKAPIClient::initSDK(string, string, ATSDKInitListener)");
|
||||
bool started = ATManager.StartSDK(appId, appKey);
|
||||
if (listener != null)
|
||||
{
|
||||
if (started)
|
||||
{
|
||||
listener.initSuccess();
|
||||
}
|
||||
else
|
||||
{
|
||||
listener.initFail("Failed to init.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback(typeof(Func<string, int>))]
|
||||
static public int DidGetUserLocation(string location)
|
||||
{
|
||||
if (locationListener != null) { locationListener.didGetUserLocation(Int32.Parse(location)); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback(typeof(Func<string, int>))]
|
||||
static public int DidUMP(string location)
|
||||
{
|
||||
if (umpListener != null) { umpListener.onConsentDismiss(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback(typeof(Func<string, int>))]
|
||||
static public int GetAreaInfo(string msg)
|
||||
{
|
||||
Debug.Log("Unity:ATSDKAPIClient::GetAreaInfo(" + msg + ")");
|
||||
if (areaListener != null)
|
||||
{
|
||||
JsonData msgJsonData = JsonMapper.ToObject(msg);
|
||||
IDictionary idic = (System.Collections.IDictionary)msgJsonData;
|
||||
|
||||
if (idic.Contains("areaCode")) {
|
||||
string areaCode = (string)msgJsonData["areaCode"];
|
||||
Debug.Log("Unity:ATSDKAPIClient::GetAreaInfo::areaCode(" + areaCode + ")");
|
||||
areaListener.onArea(areaCode);
|
||||
}
|
||||
|
||||
if (idic.Contains("errorMsg")) {
|
||||
string errorMsg = (string)msgJsonData["errorMsg"];
|
||||
Debug.Log("Unity:ATSDKAPIClient::GetAreaInfo::errorMsg(" + errorMsg + ")");
|
||||
areaListener.onError(errorMsg);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void getUserLocation(ATGetUserLocationListener listener)
|
||||
{
|
||||
Debug.Log("Unity:ATSDKAPIClient::getUserLocation()");
|
||||
ATSDKAPIClient.locationListener = listener;
|
||||
ATManager.getUserLocation(DidGetUserLocation);
|
||||
}
|
||||
|
||||
public void setGDPRLevel(int level) {
|
||||
Debug.Log("Unity:ATSDKAPIClient::setGDPRLevel()");
|
||||
ATManager.SetDataConsent(level);
|
||||
}
|
||||
|
||||
public void showGDPRAuth() {
|
||||
Debug.Log("Unity:ATSDKAPIClient::showGDPRAuth()");
|
||||
// ATManager.showGDPRAuth();
|
||||
}
|
||||
|
||||
public void showGDPRConsentDialog(ATConsentDismissListener listener)
|
||||
{
|
||||
Debug.Log("Unity:ATSDKAPIClient::showGDPRConsentDialog()");
|
||||
ATSDKAPIClient.umpListener = listener;
|
||||
ATManager.showGDPRConsentDialog(DidUMP);
|
||||
}
|
||||
|
||||
public void setPurchaseFlag() {
|
||||
ATManager.setPurchaseFlag();
|
||||
}
|
||||
|
||||
public void clearPurchaseFlag() {
|
||||
ATManager.clearPurchaseFlag();
|
||||
}
|
||||
|
||||
public bool purchaseFlag() {
|
||||
return ATManager.purchaseFlag();
|
||||
}
|
||||
|
||||
public void addNetworkGDPRInfo(int networkType, string mapJson) {
|
||||
Debug.Log("Unity:ATSDKAPIClient::addNetworkGDPRInfo()");
|
||||
ATManager.SetNetworkGDPRInfo(networkType, mapJson);
|
||||
}
|
||||
|
||||
public void setChannel(string channel)
|
||||
{
|
||||
ATManager.setChannel(channel);
|
||||
}
|
||||
|
||||
public void setSubChannel(string subchannel)
|
||||
{
|
||||
ATManager.setSubChannel(subchannel);
|
||||
}
|
||||
|
||||
public void initCustomMap(string jsonMap)
|
||||
{
|
||||
ATManager.setCustomMap(jsonMap);
|
||||
}
|
||||
|
||||
public void setCustomDataForPlacementID(string customData, string placementID)
|
||||
{
|
||||
ATManager.setCustomDataForPlacementID(customData, placementID);
|
||||
}
|
||||
|
||||
public void setLogDebug(bool isDebug)
|
||||
{
|
||||
ATManager.setLogDebug(isDebug);
|
||||
}
|
||||
|
||||
public int getGDPRLevel()
|
||||
{
|
||||
return ATManager.GetDataConsent();
|
||||
}
|
||||
|
||||
public bool isEUTraffic()
|
||||
{
|
||||
return ATManager.isEUTraffic();
|
||||
}
|
||||
|
||||
public void deniedUploadDeviceInfo(string deniedInfo)
|
||||
{
|
||||
ATManager.deniedUploadDeviceInfo(deniedInfo);
|
||||
}
|
||||
|
||||
public void setExcludeBundleIdArray(string bundleIds)
|
||||
{
|
||||
Debug.Log("Unity:ATSDKAPIClient::setExcludeBundleIdArray()");
|
||||
ATManager.setExcludeBundleIdArray(bundleIds);
|
||||
}
|
||||
|
||||
public void setExcludeAdSourceIdArrayForPlacementID(string placementID, string adSourceIds)
|
||||
{
|
||||
Debug.Log("Unity:ATSDKAPIClient::setExcludeAdSourceIdArrayForPlacementID()");
|
||||
ATManager.setExcludeAdSourceIdArrayForPlacementID(placementID, adSourceIds);
|
||||
}
|
||||
|
||||
public void setSDKArea(int area)
|
||||
{
|
||||
Debug.Log("Unity:ATSDKAPIClient::setSDKArea()");
|
||||
ATManager.setSDKArea(area);
|
||||
}
|
||||
|
||||
public void getArea(ATGetAreaListener listener)
|
||||
{
|
||||
Debug.Log("Unity:ATSDKAPIClient::getArea()");
|
||||
ATSDKAPIClient.areaListener = listener;
|
||||
ATManager.getArea(GetAreaInfo);
|
||||
}
|
||||
|
||||
public void setWXStatus(bool install)
|
||||
{
|
||||
Debug.Log("Unity:ATSDKAPIClient::setWXStatus()");
|
||||
ATManager.setWXStatus(install);
|
||||
}
|
||||
|
||||
public void setLocation(double longitude, double latitude)
|
||||
{
|
||||
Debug.Log("Unity:ATSDKAPIClient::setLocation()");
|
||||
ATManager.setLocation(longitude, latitude);
|
||||
}
|
||||
|
||||
//iOS显示Debugger UI
|
||||
public void showDebuggerUI()
|
||||
{
|
||||
Debug.Log("Unity:ATSDKAPIClient::showDebuggerUI()");
|
||||
ATManager.showDebuggerUI("");
|
||||
}
|
||||
|
||||
public void showDebuggerUI(string debugKey)
|
||||
{
|
||||
Debug.Log("Unity:ATSDKAPIClient::showDebuggerUI(debugKey)");
|
||||
ATManager.showDebuggerUI(debugKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b455aa433ae6420a9e71c7b0475cb60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,233 @@
|
||||
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 ATSplashAdClient : IATSplashAdClient {
|
||||
private ATSplashAdListener anyThinkListener;
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdShowEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdShowFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadTimeoutEvent;
|
||||
public event EventHandler<ATAdEventArgs> onDeeplinkEvent;
|
||||
public event EventHandler<ATAdEventArgs> onDownloadConfirmEvent;
|
||||
|
||||
public void addsetting(string placementId,string json){
|
||||
//todo...
|
||||
}
|
||||
|
||||
public void setListener(ATSplashAdListener listener) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::setListener()");
|
||||
anyThinkListener = listener;
|
||||
}
|
||||
|
||||
public void loadSplashAd(string placementId, int fetchAdTimeout, string defaultAdSourceConfig, string mapJson) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::loadSplashAd()");
|
||||
ATSplashAdWrapper.setClientForPlacementID(placementId, this);
|
||||
ATSplashAdWrapper.loadSplashAd(placementId, mapJson);
|
||||
}
|
||||
|
||||
public bool hasSplashAdReady(string placementId) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::hasSplashAdReady()");
|
||||
return ATSplashAdWrapper.hasSplashAdReady(placementId);
|
||||
}
|
||||
|
||||
public void showSplashAd(string placementId, string mapJson) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::showSplashAd()");
|
||||
ATSplashAdWrapper.showSplashAd(placementId, mapJson);
|
||||
}
|
||||
|
||||
public void cleanCache(string placementId) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::cleanCache()");
|
||||
ATSplashAdWrapper.clearCache(placementId);
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::checkAdStatus()");
|
||||
return ATSplashAdWrapper.checkAdStatus(placementId);
|
||||
}
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::getValidAdCaches()");
|
||||
return ATSplashAdWrapper.getValidAdCaches(placementId);
|
||||
}
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
|
||||
Debug.Log("Unity: ATSplashAdAdClient::entryScenarioWithPlacementID()");
|
||||
ATSplashAdWrapper.entryScenarioWithPlacementID(placementId,scenarioID);
|
||||
}
|
||||
|
||||
|
||||
//Callbacks
|
||||
public void OnSplashAdDeeplink(string placementID, String callbackJson, bool isSuccess) {
|
||||
onDeeplinkEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson, false, isSuccess));
|
||||
}
|
||||
|
||||
public void OnSplashAdLoadTimeout(string placementID) {
|
||||
Debug.Log("OnSplashAdLoadTimeout...unity3d.");
|
||||
onAdLoadTimeoutEvent?.Invoke(this, new ATAdEventArgs(placementID, "", true));
|
||||
}
|
||||
|
||||
public void OnSplashAdLoaded(string placementID) {
|
||||
Debug.Log("onSplashAdLoaded...unity3d.");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementID));
|
||||
}
|
||||
|
||||
public void OnSplashAdLoadFailure(string placementID, string code, string error) {
|
||||
Debug.Log("onSplashAdFailed...unity3d.");
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, code, error));
|
||||
}
|
||||
|
||||
public void OnSplashAdVideoPlayFailure(string placementID, string code, string error) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::OnSplashAdVideoPlayFailure()");
|
||||
onAdVideoFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, code, error));
|
||||
}
|
||||
|
||||
public void OnSplashAdVideoPlayStart(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::OnSplashAdPlayStart()");
|
||||
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
public void OnSplashAdVideoPlayEnd(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::OnSplashAdVideoPlayEnd()");
|
||||
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
public void OnSplashAdShow(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::OnSplashAdShow()");
|
||||
onAdShowEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
public void OnSplashAdFailedToShow(string placementID) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::OnSplashAdFailedToShow()");
|
||||
onAdShowFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, "-1", "Failed to show video ad"));
|
||||
}
|
||||
|
||||
public void OnSplashAdClick(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::OnSplashAdClick()");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
public void OnSplashAdClose(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::OnSplashAdClose()");
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
//auto callbacks
|
||||
public void startLoadingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::startLoadingADSource()");
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void finishLoadingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::finishLoadingADSource()");
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void failToLoadADSource(string placementId, string callbackJson,string code, string error)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::failToLoadADSource()");
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
public void startBiddingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::startBiddingADSource()");
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void finishBiddingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::finishBiddingADSource()");
|
||||
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void failBiddingADSource(string placementId,string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::failBiddingADSource()");
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
|
||||
// Auto
|
||||
public void addAutoLoadAdPlacementID(string[] placementIDList)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient:addAutoLoadAdPlacementID()");
|
||||
|
||||
|
||||
|
||||
if (placementIDList != null && placementIDList.Length > 0)
|
||||
{
|
||||
foreach (string placementID in placementIDList)
|
||||
{
|
||||
ATSplashAdWrapper.setClientForPlacementID(placementID, this);
|
||||
}
|
||||
|
||||
string placementIDListString = JsonMapper.ToJson(placementIDList);
|
||||
ATSplashAdWrapper.addAutoLoadAdPlacementID(placementIDListString);
|
||||
Debug.Log("addAutoLoadAdPlacementID, placementIDList === " + placementIDListString);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("addAutoLoadAdPlacementID, placementIDList = null");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void removeAutoLoadAdPlacementID(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient:removeAutoLoadAdPlacementID()");
|
||||
ATSplashAdWrapper.removeAutoLoadAdPlacementID(placementId);
|
||||
}
|
||||
|
||||
public bool autoLoadSplashAdReadyForPlacementID(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient:autoLoadSplashAdReadyForPlacementID()");
|
||||
return ATSplashAdWrapper.autoLoadSplashAdReadyForPlacementID(placementId);
|
||||
}
|
||||
public string getAutoValidAdCaches(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient:getAutoValidAdCaches()");
|
||||
return ATSplashAdWrapper.getAutoValidAdCaches(placementId);
|
||||
}
|
||||
|
||||
public string checkAutoAdStatus(string placementId) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::checkAutoAdStatus()");
|
||||
return ATSplashAdWrapper.checkAutoAdStatus(placementId);
|
||||
}
|
||||
|
||||
|
||||
public void setAutoLocalExtra(string placementId, string mapJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient:setAutoLocalExtra()");
|
||||
ATSplashAdWrapper.setAutoLocalExtra(placementId, mapJson);
|
||||
}
|
||||
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient:entryAutoAdScenarioWithPlacementID()");
|
||||
ATSplashAdWrapper.entryAutoAdScenarioWithPlacementID(placementId, scenarioID);
|
||||
}
|
||||
public void showAutoAd(string placementId, string mapJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::showAutoAd()");
|
||||
ATSplashAdWrapper.showAutoSplashAd(placementId, mapJson);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 480a1fa0d5e0e4783be24ce7ff84b3a0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e1a828ee252c4a6bb226d2e51fcd5aa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d98d4308064f4d08b78dd057af3bb59
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// ATAutolayoutCategories.h
|
||||
// ATSDKDemo
|
||||
//
|
||||
// Created by Martin Lau on 24/04/2018.
|
||||
// Copyright © 2018 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UIView(Autolayout)
|
||||
+(instancetype) autolayoutView;
|
||||
- (NSArray<__kindof NSLayoutConstraint *> *)addConstraintsWithVisualFormat:(NSString *)format options:(NSLayoutFormatOptions)opts metrics:(NSDictionary<NSString *,id> *)metrics views:(NSDictionary<NSString *, id> *)views;
|
||||
-(NSLayoutConstraint*)addConstraintWithItem:(id)view1 attribute:(NSLayoutAttribute)attr1 relatedBy:(NSLayoutRelation)relation toItem:(id)view2 attribute:(NSLayoutAttribute)attr2 multiplier:(CGFloat)multiplier constant:(CGFloat)c;
|
||||
@end
|
||||
|
||||
@interface UILabel(Autolayout)
|
||||
+(instancetype) autolayoutLabelFont:(UIFont*)font textColor:(UIColor*)textColor textAlignment:(NSTextAlignment)textAlignment;
|
||||
/**
|
||||
* textAlignment defaults to NSTextAlignmentLeft
|
||||
*/
|
||||
+(instancetype) autolayoutLabelFont:(UIFont*)font textColor:(UIColor*)textColor;
|
||||
@end
|
||||
|
||||
@interface UIButton(Autolayout)
|
||||
+(instancetype) autolayoutButtonWithType:(UIButtonType)type;
|
||||
@end
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c07c3e4484ec24577b99e2506433f339
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// ATAutolayoutCategories.m
|
||||
// ATSDKDemo
|
||||
//
|
||||
// Created by Martin Lau on 24/04/2018.
|
||||
// Copyright © 2018 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ATAutolayoutCategories.h"
|
||||
|
||||
@implementation UIView(Autolayout)
|
||||
+(instancetype) autolayoutView {
|
||||
UIView *view = [[self alloc] init];
|
||||
view.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
return view;
|
||||
}
|
||||
|
||||
- (NSArray<__kindof NSLayoutConstraint *> *)addConstraintsWithVisualFormat:(NSString *)format options:(NSLayoutFormatOptions)opts metrics:(NSDictionary<NSString *,id> *)metrics views:(NSDictionary<NSString *, id> *)views {
|
||||
NSArray<__kindof NSLayoutConstraint*>* constraints = [NSLayoutConstraint constraintsWithVisualFormat:format options:opts metrics:metrics views:views];
|
||||
[self addConstraints:constraints];
|
||||
return constraints;
|
||||
}
|
||||
|
||||
-(NSLayoutConstraint*)addConstraintWithItem:(id)view1 attribute:(NSLayoutAttribute)attr1 relatedBy:(NSLayoutRelation)relation toItem:(id)view2 attribute:(NSLayoutAttribute)attr2 multiplier:(CGFloat)multiplier constant:(CGFloat)c {
|
||||
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:view1 attribute:attr1 relatedBy:relation toItem:view2 attribute:attr2 multiplier:multiplier constant:c];
|
||||
[self addConstraint:constraint];
|
||||
return constraint;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation UILabel(Autolayout)
|
||||
+(instancetype) autolayoutLabelFont:(UIFont*)font textColor:(UIColor*)textColor textAlignment:(NSTextAlignment)textAlignment {
|
||||
UILabel *label = [UILabel autolayoutView];
|
||||
label.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
label.font = font;
|
||||
label.textColor = textColor;
|
||||
label.textAlignment = textAlignment;
|
||||
return label;
|
||||
}
|
||||
|
||||
+(instancetype) autolayoutLabelFont:(UIFont*)font textColor:(UIColor*)textColor {
|
||||
return [self autolayoutLabelFont:font textColor:textColor textAlignment:NSTextAlignmentLeft];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation UIButton(Autolayout)
|
||||
+(instancetype) autolayoutButtonWithType:(UIButtonType)type {
|
||||
UIButton *button = [UIButton buttonWithType:type];
|
||||
button.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
return button;
|
||||
}
|
||||
@end
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e8d6d95be73a4957bd61c6856f1cdff
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// ATBannerAdWrapper.h
|
||||
// UnityContainer
|
||||
//
|
||||
// Created by Martin Lau on 2019/1/8.
|
||||
// Copyright © 2019 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ATBaseUnityWrapper.h"
|
||||
|
||||
@interface ATBannerAdWrapper : ATBaseUnityWrapper
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 853f77b4d0a4f4474b7398219213a34b
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,263 @@
|
||||
//
|
||||
// ATBannerAdWrapper.m
|
||||
// UnityContainer
|
||||
//
|
||||
// Created by Martin Lau on 2019/1/8.
|
||||
// Copyright © 2019 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ATBannerAdWrapper.h"
|
||||
#import <AnyThinkBanner/AnyThinkBanner.h>
|
||||
#import "ATUnityUtilities.h"
|
||||
//5.6.6版本以上支持 admob 自适应banner (用到时再import该头文件)
|
||||
//#import <GoogleMobileAds/GoogleMobileAds.h>
|
||||
|
||||
@interface ATBannerAdWrapper()<ATBannerDelegate>
|
||||
@property(nonatomic, readonly) NSMutableDictionary<NSString*, ATBannerView*> *bannerViewStorage;
|
||||
@property(nonatomic, readonly) BOOL interstitialOrRVBeingShown;
|
||||
@end
|
||||
|
||||
static NSString *kATBannerSizeUsesPixelFlagKey = @"uses_pixel";
|
||||
static NSString *kATBannerAdLoadingExtraInlineAdaptiveWidthKey = @"inline_adaptive_width";
|
||||
static NSString *kATBannerAdLoadingExtraInlineAdaptiveOrientationKey = @"inline_adaptive_orientation";
|
||||
|
||||
@implementation ATBannerAdWrapper
|
||||
+(instancetype)sharedInstance {
|
||||
static ATBannerAdWrapper *sharedInstance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [[ATBannerAdWrapper alloc] init];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
-(instancetype) init {
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_bannerViewStorage = [NSMutableDictionary<NSString*, ATBannerView*> dictionary];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(NSString*) scriptWrapperClass {
|
||||
return @"ATBannerAdWrapper";
|
||||
}
|
||||
|
||||
- (id)selWrapperClassWithDict:(NSDictionary *)dict callback:(void(*)(const char*, const char*))callback {
|
||||
NSString *selector = dict[@"selector"];
|
||||
NSArray<NSString*>* arguments = dict[@"arguments"];
|
||||
NSString *firstObject = @"";
|
||||
NSString *secondObject = @"";
|
||||
NSString *lastObject = @"";
|
||||
if (![ATUnityUtilities isEmpty:arguments]) {
|
||||
for (int i = 0; i < arguments.count; i++) {
|
||||
if (i == 0) { firstObject = arguments[i]; }
|
||||
else if (i == 1) { secondObject = arguments[i]; }
|
||||
else { lastObject = arguments[i]; }
|
||||
}
|
||||
}
|
||||
|
||||
if ([selector isEqualToString:@"loadBannerAdWithPlacementID:customDataJSONString:callback:"]) {
|
||||
[self loadBannerAdWithPlacementID:firstObject customDataJSONString:secondObject callback:callback];
|
||||
} else if ([selector isEqualToString:@"showBannerAdWithPlacementID:rect:extraJsonString:"]) {
|
||||
[self showBannerAdWithPlacementID:firstObject rect:secondObject extraJsonString:lastObject];
|
||||
} else if ([selector isEqualToString:@"removeBannerAdWithPlacementID:"]) {
|
||||
[self removeBannerAdWithPlacementID:firstObject];
|
||||
} else if ([selector isEqualToString:@"showBannerAdWithPlacementID:"]) {
|
||||
[self showBannerAdWithPlacementID:firstObject];
|
||||
} else if ([selector isEqualToString:@"hideBannerAdWithPlacementID:"]) {
|
||||
[self hideBannerAdWithPlacementID:firstObject];
|
||||
} else if ([selector isEqualToString:@"checkAdStatus:"]) {
|
||||
return [self checkAdStatus:firstObject];
|
||||
} else if ([selector isEqualToString:@"clearCache"]) {
|
||||
[self clearCache];
|
||||
} else if ([selector isEqualToString:@"getValidAdCaches:"]) {
|
||||
return [self getValidAdCaches:firstObject];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(void) loadBannerAdWithPlacementID:(NSString*)placementID customDataJSONString:(NSString*)customDataJSONString callback:(void(*)(const char*, const char*))callback {
|
||||
[self setCallBack:callback forKey:placementID];
|
||||
NSMutableDictionary *extra = [NSMutableDictionary dictionary];
|
||||
if ([customDataJSONString isKindOfClass:[NSString class]] && [customDataJSONString length] > 0) {
|
||||
NSDictionary *extraDict = [NSJSONSerialization JSONObjectWithData:[customDataJSONString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
NSLog(@"extraDict = %@", extraDict);
|
||||
CGFloat scale = [extraDict[kATBannerSizeUsesPixelFlagKey] boolValue] ? [UIScreen mainScreen].nativeScale : 1.0f;
|
||||
if ([extraDict[kATAdLoadingExtraBannerAdSizeKey] isKindOfClass:[NSString class]] && [[extraDict[kATAdLoadingExtraBannerAdSizeKey] componentsSeparatedByString:@"x"] count] == 2) {
|
||||
NSArray<NSString*>* com = [extraDict[kATAdLoadingExtraBannerAdSizeKey] componentsSeparatedByString:@"x"];
|
||||
|
||||
extra[kATAdLoadingExtraBannerAdSizeKey] = [NSValue valueWithCGSize:CGSizeMake([com[0] doubleValue] / scale, [com[1] doubleValue] / scale)];
|
||||
}
|
||||
|
||||
// // admob 自适应banner,5.6.6版本以上支持
|
||||
// if (extraDict[kATBannerAdLoadingExtraInlineAdaptiveWidthKey] != nil && extraDict[kATBannerAdLoadingExtraInlineAdaptiveOrientationKey] != nil) {
|
||||
// //GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth 自适应
|
||||
// //GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth 竖屏
|
||||
// //GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth 横屏
|
||||
// CGFloat admobBannerWidth = [extraDict[kATBannerAdLoadingExtraInlineAdaptiveWidthKey] doubleValue];
|
||||
// GADAdSize admobSize;
|
||||
// if ([extraDict[kATBannerAdLoadingExtraInlineAdaptiveOrientationKey] integerValue] == 1) {
|
||||
// admobSize = GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(admobBannerWidth);
|
||||
// } else if ([extraDict[kATBannerAdLoadingExtraInlineAdaptiveOrientationKey] integerValue] == 2) {
|
||||
// admobSize = GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(admobBannerWidth);
|
||||
// } else {
|
||||
// admobSize = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(admobBannerWidth);
|
||||
// }
|
||||
//
|
||||
// extra[kATAdLoadingExtraAdmobBannerSizeKey] = [NSValue valueWithCGSize:admobSize.size];
|
||||
// extra[kATAdLoadingExtraAdmobAdSizeFlagsKey] = @(admobSize.flags);
|
||||
// }
|
||||
}
|
||||
if (extra[kATAdLoadingExtraBannerAdSizeKey] == nil) {
|
||||
extra[kATAdLoadingExtraBannerAdSizeKey] = [NSValue valueWithCGSize:CGSizeMake(320.0f, 50.0f)];
|
||||
}
|
||||
NSLog(@"extra = %@", extra);
|
||||
[[ATAdManager sharedManager] loadADWithPlacementID:placementID extra:extra delegate:self];
|
||||
}
|
||||
|
||||
-(NSString*) checkAdStatus:(NSString *)placementID {
|
||||
ATCheckLoadModel *checkLoadModel = [[ATAdManager sharedManager] checkBannerLoadStatusForPlacementID:placementID];
|
||||
NSMutableDictionary *statusDict = [NSMutableDictionary dictionary];
|
||||
statusDict[@"isLoading"] = @(checkLoadModel.isLoading);
|
||||
statusDict[@"isReady"] = @(checkLoadModel.isReady);
|
||||
statusDict[@"adInfo"] = checkLoadModel.adOfferInfo;
|
||||
NSLog(@"ATBannerAdWrapper::statusDict = %@", statusDict);
|
||||
return statusDict.jsonFilterString;
|
||||
}
|
||||
|
||||
-(NSString*) getValidAdCaches:(NSString *)placementID {
|
||||
NSArray *array = [[ATAdManager sharedManager] getBannerValidAdsForPlacementID:placementID];
|
||||
NSLog(@"ATNativeAdWrapper::array = %@", array);
|
||||
return array.jsonFilterString;
|
||||
}
|
||||
|
||||
UIEdgeInsets SafeAreaInsets_ATUnityBanner() {
|
||||
return ([[UIApplication sharedApplication].keyWindow respondsToSelector:@selector(safeAreaInsets)] ? [UIApplication sharedApplication].keyWindow.safeAreaInsets : UIEdgeInsetsZero);
|
||||
}
|
||||
|
||||
-(void) showBannerAdWithPlacementID:(NSString*)placementID rect:(NSString*)rect extraJsonString:(NSString*)extraJsonString {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if ([rect isKindOfClass:[NSString class]] && [rect dataUsingEncoding:NSUTF8StringEncoding] != nil) {
|
||||
NSDictionary *extraDict = ([extraJsonString isKindOfClass:[NSString class]] && [extraJsonString dataUsingEncoding:NSUTF8StringEncoding] != nil) ? [NSJSONSerialization JSONObjectWithData:[extraJsonString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil] : nil;
|
||||
|
||||
NSDictionary *rectDict = [NSJSONSerialization JSONObjectWithData:[rect dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
NSLog(@"rectDict = %@", rectDict);
|
||||
CGFloat scale = [rectDict[kATBannerSizeUsesPixelFlagKey] boolValue] ? [UIScreen mainScreen].nativeScale : 1.0f;
|
||||
ATBannerView *bannerView = [[ATAdManager sharedManager] retrieveBannerViewForPlacementID:placementID scene:extraDict[kATUnityUtilitiesAdShowingExtraScenarioKey]];
|
||||
bannerView.delegate = self;
|
||||
UIButton *bannerCointainer = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[bannerCointainer addTarget:self action:@selector(noop) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
NSString *position = rectDict[@"position"];
|
||||
CGSize totalSize = [UIApplication sharedApplication].keyWindow.rootViewController.view.bounds.size;
|
||||
UIEdgeInsets safeAreaInsets = SafeAreaInsets_ATUnityBanner();
|
||||
if ([@"top" isEqualToString:position]) {
|
||||
bannerCointainer.frame = CGRectMake((totalSize.width - CGRectGetWidth(bannerView.bounds)) / 2.0f, safeAreaInsets.top , CGRectGetWidth(bannerView.bounds), CGRectGetHeight(bannerView.bounds));
|
||||
} else if ([@"bottom" isEqualToString:position]) {
|
||||
bannerCointainer.frame = CGRectMake((totalSize.width - CGRectGetWidth(bannerView.bounds)) / 2.0f, totalSize.height - safeAreaInsets.bottom - CGRectGetHeight(bannerView.bounds) , CGRectGetWidth(bannerView.bounds), CGRectGetHeight(bannerView.bounds));
|
||||
} else {
|
||||
bannerCointainer.frame = CGRectMake([rectDict[@"x"] doubleValue] / scale, [rectDict[@"y"] doubleValue] / scale, [rectDict[@"width"] doubleValue] / scale, [rectDict[@"height"] doubleValue] / scale);
|
||||
}
|
||||
|
||||
bannerView.frame = bannerCointainer.bounds;
|
||||
[bannerCointainer addSubview:bannerView];
|
||||
|
||||
// bannerCointainer.layer.borderColor = [UIColor redColor].CGColor;
|
||||
// bannerCointainer.layer.borderWidth = .5f;
|
||||
[[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:bannerCointainer];
|
||||
self->_bannerViewStorage[placementID] = bannerCointainer;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
-(void) noop {
|
||||
|
||||
}
|
||||
|
||||
-(void) removeBannerAdWithPlacementID:(NSString*)placementID {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self->_bannerViewStorage[placementID] removeFromSuperview];
|
||||
[self->_bannerViewStorage removeObjectForKey:placementID];
|
||||
});
|
||||
}
|
||||
|
||||
-(void) showBannerAdWithPlacementID:(NSString*)placementID {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
ATBannerView *bannerView = self->_bannerViewStorage[placementID];
|
||||
if (bannerView.superview != nil && !_interstitialOrRVBeingShown) { bannerView.hidden = NO; }
|
||||
});
|
||||
}
|
||||
|
||||
-(void) hideBannerAdWithPlacementID:(NSString*)placementID {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
ATBannerView *bannerView = self->_bannerViewStorage[placementID];
|
||||
if (bannerView.superview != nil) { bannerView.hidden = YES; }
|
||||
});
|
||||
}
|
||||
|
||||
-(void) clearCache {
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - banner delegate method(s)
|
||||
-(void) didFinishLoadingADWithPlacementID:(NSString *)placementID {
|
||||
[self invokeCallback:@"OnBannerAdLoad" placementID:placementID error:nil extra:nil];
|
||||
}
|
||||
|
||||
-(void) didFailToLoadADWithPlacementID:(NSString*)placementID error:(NSError*)error {
|
||||
error = error != nil ? error : [NSError errorWithDomain:@"com.thinkup.Unity3DPackage" code:100001 userInfo:@{NSLocalizedDescriptionKey:@"AT has failed to load ad", NSLocalizedFailureReasonErrorKey:@"AT has failed to load ad"}];
|
||||
[self invokeCallback:@"OnBannerAdLoadFail" placementID:placementID error:error extra:nil];
|
||||
}
|
||||
// ad
|
||||
- (void)didStartLoadingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"startLoadingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFinishLoadingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"finishLoadingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFailToLoadADSourceWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra error:(NSError*)error{
|
||||
[self invokeCallback:@"failToLoadADSource" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
// bidding
|
||||
- (void)didStartBiddingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"startBiddingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFinishBiddingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"finishBiddingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFailBiddingADSourceWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra error:(NSError*)error{
|
||||
[self invokeCallback:@"failBiddingADSource" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
-(void) bannerView:(ATBannerView *)bannerView didShowAdWithPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnBannerAdImpress" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) bannerView:(ATBannerView*)bannerView didClickWithPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnBannerAdClick" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) bannerView:(ATBannerView *)bannerView didTapCloseButtonWithPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnBannerAdCloseButtonTapped" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) bannerView:(ATBannerView*)bannerView didCloseWithPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnBannerAdClose" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) bannerView:(ATBannerView *)bannerView didAutoRefreshWithPlacement:(NSString *)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnBannerAdAutoRefresh" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) bannerView:(ATBannerView *)bannerView failedToAutoRefreshWithPlacementID:(NSString *)placementID error:(NSError *)error {
|
||||
error = error != nil ? error : [NSError errorWithDomain:@"com.thinkup.Unity3DPackage" code:100001 userInfo:@{NSLocalizedDescriptionKey:@"AT has failed to refresh ad", NSLocalizedFailureReasonErrorKey:@"AT has failed to refresh ad"}];
|
||||
[self invokeCallback:@"OnBannerAdAutoRefreshFail" placementID:placementID error:error extra:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1fc6c95a98954a9abf0594931d54747
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// ATBaseUnityWrapper.h
|
||||
// UnityContainer
|
||||
//
|
||||
// Created by Martin Lau on 08/08/2018.
|
||||
// Copyright © 2018 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ATUnityWrapper.h"
|
||||
@interface ATBaseUnityWrapper : NSObject<ATUnityWrapper>
|
||||
-(NSString*)scriptWrapperClass;
|
||||
-(id)selWrapperClassWithDict:(NSDictionary *)dict callback:(void(*)(const char*, const char*))callback;
|
||||
-(void) invokeCallback:(NSString*)callback placementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary*)extra;
|
||||
- (NSArray *)jsonStrToArray:(NSString *)jsonString;
|
||||
@end
|
||||
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d081fc06eb89e463ca8e7b93a8fc13fc
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,155 @@
|
||||
//
|
||||
// ATBaseUnityWrapper.m
|
||||
// UnityContainer
|
||||
//
|
||||
// Created by Martin Lau on 08/08/2018.
|
||||
// Copyright © 2018 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ATBaseUnityWrapper.h"
|
||||
#import "ATUnityUtilities.h"
|
||||
#import "ATUnitySafeThreadDictionary.h"
|
||||
@interface ATBaseUnityWrapper()
|
||||
@property(nonatomic, strong) ATUnitySafeThreadDictionary<NSString*, NSValue*> *callbacks;
|
||||
@end
|
||||
@implementation ATBaseUnityWrapper
|
||||
+(instancetype) sharedInstance {
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(instancetype) init {
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_callbacks = [ATUnitySafeThreadDictionary<NSString*, NSValue*> dictionary];
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) setCallBack:(void (*)(const char *, const char *))callback forKey:(NSString *)key {
|
||||
__weak ATBaseUnityWrapper* weakSelf = self;
|
||||
if (callback != NULL && [key length] > 0) {
|
||||
[self.callbacks setValue:[NSValue valueWithPointer:(void*)callback] forKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) removeCallbackForKey:(NSString *)key {
|
||||
if ([key length] > 0) {
|
||||
[self.callbacks removeObjectForKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
-(void(*)(const char*, const char *)) callbackForKey:(NSString*)key {
|
||||
__block void(*callback)(const char*, const char *) = NULL;
|
||||
if ([key length] > 0) {
|
||||
callback = (void(*)(const char*, const char *))[self.callbacks[key] pointerValue];
|
||||
}
|
||||
return callback;
|
||||
}
|
||||
|
||||
-(NSString*)scriptWrapperClass {
|
||||
return @"";
|
||||
}
|
||||
|
||||
- (id)selWrapperClassWithDict:(NSDictionary *)dict callback:(void(*)(const char*, const char*))callback {
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(void) invokeCallback:(NSString*)callback placementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary*)extraParams {
|
||||
|
||||
__block NSDictionary* extra = extraParams;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
@try {
|
||||
|
||||
if ([self callbackForKey:placementID] != NULL) {
|
||||
if ([callback isKindOfClass:[NSString class]] && [callback length] > 0) {
|
||||
|
||||
NSMutableDictionary *paraDict = [NSMutableDictionary dictionaryWithObject:callback forKey:@"callback"];
|
||||
|
||||
NSMutableDictionary *msgDict = [NSMutableDictionary dictionary];
|
||||
|
||||
if (![ATUnityUtilities isEmpty:extra]) {
|
||||
|
||||
// 过滤SDK返回参数的 user_load_extra_data 中不支持的类型
|
||||
if (extra[kATUnityUserExtraDataKey] != nil) {
|
||||
NSMutableDictionary *extraDictM = [NSMutableDictionary dictionaryWithDictionary:extra];
|
||||
NSMutableDictionary *extraDataTemp = [NSMutableDictionary dictionary];
|
||||
NSMutableDictionary *extraDataDictM = [NSMutableDictionary dictionaryWithDictionary:extra[kATUnityUserExtraDataKey]];
|
||||
for (NSString *key in extraDataDictM.allKeys) {
|
||||
if ([extraDataDictM[key] isKindOfClass:[NSString class]] || [extraDataDictM[key] isKindOfClass:[NSNumber class]]) {
|
||||
[extraDataTemp setValue:extraDataDictM[key] forKey:key];
|
||||
}
|
||||
}
|
||||
if ([extraDataTemp count]) {
|
||||
[extraDictM setValue:extraDataTemp forKey:kATUnityUserExtraDataKey];
|
||||
} else {
|
||||
[extraDictM removeObjectForKey:kATUnityUserExtraDataKey];
|
||||
}
|
||||
extra = extraDictM;
|
||||
}
|
||||
|
||||
if (extra[@"extra"] != nil) {
|
||||
msgDict[@"extra"] = extra[@"extra"];
|
||||
msgDict[@"rewarded"] = extra[@"rewarded"];
|
||||
} else {
|
||||
msgDict[@"extra"] = extra;
|
||||
}
|
||||
}
|
||||
|
||||
paraDict[@"msg"] = msgDict;
|
||||
|
||||
if ([placementID isKindOfClass:[NSString class]] && ![ATUnityUtilities isEmpty:placementID]) {
|
||||
msgDict[@"placement_id"] = placementID;
|
||||
};
|
||||
|
||||
if ([error isKindOfClass:[NSError class]]) {
|
||||
|
||||
NSMutableDictionary *errorDict = [NSMutableDictionary dictionaryWithObject:[NSString stringWithFormat:@"%ld", error.code] forKey:@"code"];
|
||||
|
||||
if (![ATUnityUtilities isEmpty:error.userInfo[NSLocalizedDescriptionKey]]) {
|
||||
errorDict[@"desc"] = [NSString stringWithFormat:@"%@",error.userInfo[NSLocalizedDescriptionKey]];
|
||||
} else {
|
||||
errorDict[@"desc"] = @"";
|
||||
}
|
||||
if (![ATUnityUtilities isEmpty:error.userInfo[NSLocalizedFailureReasonErrorKey]]) {
|
||||
errorDict[@"reason"] = [NSString stringWithFormat:@"%@",error.userInfo[NSLocalizedFailureReasonErrorKey]];
|
||||
} else {
|
||||
errorDict[@"reason"] = @"";
|
||||
}
|
||||
msgDict[@"error"] = errorDict;
|
||||
}
|
||||
|
||||
[self callbackForKey:placementID]([self scriptWrapperClass].UTF8String, paraDict.jsonString.UTF8String);
|
||||
}
|
||||
}
|
||||
} @catch (NSException *exception) {
|
||||
|
||||
} @finally {}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
- (NSArray *)jsonStrToArray:(NSString *)jsonString{
|
||||
|
||||
|
||||
NSError *error;
|
||||
NSArray *array = [NSArray array];
|
||||
|
||||
@try {
|
||||
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
array = [NSJSONSerialization JSONObjectWithData:jsonData
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
if(error){
|
||||
return [NSArray array];
|
||||
}
|
||||
} @catch (NSException *exception) {
|
||||
NSLog(@"jsonStrToArray --- exception:%@",exception);
|
||||
} @finally {}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b39c633e4f63b403da8036b227ba2f5c
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// ATInterstitialAdWrapper.h
|
||||
// UnityContainer
|
||||
//
|
||||
// Created by Martin Lau on 2019/1/8.
|
||||
// Copyright © 2019 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ATBaseUnityWrapper.h"
|
||||
@interface ATInterstitialAdWrapper : ATBaseUnityWrapper
|
||||
|
||||
@end
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c34a9bf3d4ee144509a47965d0f358de
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+309
@@ -0,0 +1,309 @@
|
||||
//
|
||||
// ATInterstitialAdWrapper.m
|
||||
// UnityContainer
|
||||
//
|
||||
// Created by Martin Lau on 2019/1/8.
|
||||
// Copyright © 2019 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ATInterstitialAdWrapper.h"
|
||||
#import "ATUnityUtilities.h"
|
||||
#import <AnyThinkInterstitial/AnyThinkInterstitial.h>
|
||||
|
||||
NSString *const kLoadUseRVAsInterstitialKey = @"UseRewardedVideoAsInterstitial";
|
||||
NSString *const kInterstitialExtraAdSizeKey = @"interstitial_ad_size";
|
||||
static NSString *kATInterstitialSizeUsesPixelFlagKey = @"uses_pixel";
|
||||
|
||||
@interface ATInterstitialAdWrapper()<ATInterstitialDelegate>
|
||||
@end
|
||||
@implementation ATInterstitialAdWrapper
|
||||
+(instancetype)sharedInstance {
|
||||
static ATInterstitialAdWrapper *sharedInstance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [[ATInterstitialAdWrapper alloc] init];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
-(NSString*) scriptWrapperClass {
|
||||
return @"ATInterstitialAdWrapper";
|
||||
}
|
||||
|
||||
- (id)selWrapperClassWithDict:(NSDictionary *)dict callback:(void(*)(const char*, const char*))callback {
|
||||
NSString *selector = dict[@"selector"];
|
||||
NSArray<NSString*>* arguments = dict[@"arguments"];
|
||||
NSString *firstObject = @"";
|
||||
NSString *lastObject = @"";
|
||||
if (![ATUnityUtilities isEmpty:arguments]) {
|
||||
for (int i = 0; i < arguments.count; i++) {
|
||||
if (i == 0) { firstObject = arguments[i]; }
|
||||
else { lastObject = arguments[i]; }
|
||||
}
|
||||
}
|
||||
|
||||
if ([selector isEqualToString:@"loadInterstitialAdWithPlacementID:customDataJSONString:callback:"]) {
|
||||
[self loadInterstitialAdWithPlacementID:firstObject customDataJSONString:lastObject callback:callback];
|
||||
} else if ([selector isEqualToString:@"interstitialAdReadyForPlacementID:"]) {
|
||||
return [NSNumber numberWithBool:[self interstitialAdReadyForPlacementID:firstObject]];
|
||||
} else if ([selector isEqualToString:@"showInterstitialAdWithPlacementID:extraJsonString:"]) {
|
||||
[self showInterstitialAdWithPlacementID:firstObject extraJsonString:lastObject];
|
||||
} else if ([selector isEqualToString:@"checkAdStatus:"]) {
|
||||
return [self checkAdStatus:firstObject];
|
||||
} else if ([selector isEqualToString:@"clearCache"]) {
|
||||
[self clearCache];
|
||||
} else if ([selector isEqualToString:@"getValidAdCaches:"]) {
|
||||
return [self getValidAdCaches:firstObject];
|
||||
}else if ([selector isEqualToString:@"entryScenarioWithPlacementID:scenarioID:"]) {
|
||||
[self entryScenarioWithPlacementID:firstObject scenarioID:lastObject];
|
||||
}
|
||||
// auto
|
||||
else if ([selector isEqualToString:@"addAutoLoadAdPlacementID:callback:"]){
|
||||
[self addAutoLoadAdPlacementID:firstObject callback:callback];
|
||||
}else if ([selector isEqualToString:@"removeAutoLoadAdPlacementID:"]){
|
||||
[self removeAutoLoadAdPlacementID:firstObject];
|
||||
}else if ([selector isEqualToString:@"autoLoadInterstitialAdReadyForPlacementID:"]){
|
||||
return [NSNumber numberWithBool:[self autoLoadInterstitialAdReadyForPlacementID:firstObject]];
|
||||
}else if ([selector isEqualToString:@"getAutoValidAdCaches:"]){
|
||||
return [self getAutoValidAdCaches:firstObject];
|
||||
}else if ([selector isEqualToString:@"setAutoLocalExtra:customDataJSONString:"]){
|
||||
[self setAutoLocalExtra:firstObject customDataJSONString:lastObject];
|
||||
}else if ([selector isEqualToString:@"entryAutoAdScenarioWithPlacementID:scenarioID:"]){
|
||||
[self entryAutoAdScenarioWithPlacementID:firstObject scenarioID:lastObject];
|
||||
}else if ([selector isEqualToString:@"showAutoInterstitialAd:extraJsonString:"]){
|
||||
[self showAutoInterstitialAd:firstObject extraJsonString:lastObject];
|
||||
}else if ([selector isEqualToString:@"checkAutoAdStatus:"]) {
|
||||
return [self checkAutoAdStatus:firstObject];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(void) loadInterstitialAdWithPlacementID:(NSString*)placementID customDataJSONString:(NSString*)customDataJSONString callback:(void(*)(const char*, const char*))callback {
|
||||
|
||||
[self setCallBack:callback forKey:placementID];
|
||||
NSMutableDictionary *extra = [NSMutableDictionary dictionary];
|
||||
if ([customDataJSONString isKindOfClass:[NSString class]] && [customDataJSONString length] > 0) {
|
||||
NSDictionary *extraDict = [NSJSONSerialization JSONObjectWithData:[customDataJSONString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
NSLog(@"extraDict = %@", extraDict);
|
||||
if (extraDict[kLoadUseRVAsInterstitialKey] != nil) {
|
||||
extra[kATInterstitialExtraUsesRewardedVideo] = @([extraDict[kLoadUseRVAsInterstitialKey] boolValue]);
|
||||
}
|
||||
|
||||
CGFloat scale = [extraDict[kATInterstitialSizeUsesPixelFlagKey] boolValue] ? [UIScreen mainScreen].nativeScale : 1.0f;
|
||||
if ([extraDict[kInterstitialExtraAdSizeKey] isKindOfClass:[NSString class]] && [[extraDict[kInterstitialExtraAdSizeKey] componentsSeparatedByString:@"x"] count] == 2) {
|
||||
NSArray<NSString*>* com = [extraDict[kInterstitialExtraAdSizeKey] componentsSeparatedByString:@"x"];
|
||||
extra[kATInterstitialExtraAdSizeKey] = [NSValue valueWithCGSize:CGSizeMake([com[0] doubleValue] / scale, [com[1] doubleValue] / scale)];
|
||||
}
|
||||
}
|
||||
|
||||
NSLog(@"ATInterstitialAdWrapper::extra = %@", extra);
|
||||
[[ATAdManager sharedManager] loadADWithPlacementID:placementID extra:extra != nil ? extra : nil delegate:self];
|
||||
}
|
||||
|
||||
-(BOOL) interstitialAdReadyForPlacementID:(NSString*)placementID {
|
||||
return [[ATAdManager sharedManager] interstitialReadyForPlacementID:placementID];
|
||||
}
|
||||
|
||||
-(NSString*) getValidAdCaches:(NSString *)placementID {
|
||||
NSArray *array = [[ATAdManager sharedManager] getInterstitialValidAdsForPlacementID:placementID];
|
||||
NSLog(@"ATNativeAdWrapper::array = %@", array);
|
||||
return array.jsonFilterString;
|
||||
}
|
||||
|
||||
-(void) showInterstitialAdWithPlacementID:(NSString*)placementID extraJsonString:(NSString*)extraJsonString {
|
||||
NSDictionary *extraDict = ([extraJsonString isKindOfClass:[NSString class]] && [extraJsonString dataUsingEncoding:NSUTF8StringEncoding] != nil) ? [NSJSONSerialization JSONObjectWithData:[extraJsonString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil] : nil;
|
||||
[[ATAdManager sharedManager] showInterstitialWithPlacementID:placementID scene:extraDict[kATUnityUtilitiesAdShowingExtraScenarioKey] inViewController:[UIApplication sharedApplication].delegate.window.rootViewController delegate:self];
|
||||
}
|
||||
|
||||
-(NSString*) checkAdStatus:(NSString *)placementID {
|
||||
ATCheckLoadModel *checkLoadModel = [[ATAdManager sharedManager] checkInterstitialLoadStatusForPlacementID:placementID];
|
||||
NSMutableDictionary *statusDict = [NSMutableDictionary dictionary];
|
||||
statusDict[@"isLoading"] = @(checkLoadModel.isLoading);
|
||||
statusDict[@"isReady"] = @(checkLoadModel.isReady);
|
||||
statusDict[@"adInfo"] = checkLoadModel.adOfferInfo;
|
||||
NSLog(@"ATInterstitialAdWrapper::statusDict = %@", statusDict);
|
||||
return statusDict.jsonFilterString;
|
||||
}
|
||||
- (void)entryScenarioWithPlacementID:(NSString *)placementID scenarioID:(NSString *)scenarioID{
|
||||
|
||||
[[ATAdManager sharedManager] entryInterstitialScenarioWithPlacementID:placementID scene:scenarioID];
|
||||
}
|
||||
-(void) clearCache {
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - auto
|
||||
-(void) addAutoLoadAdPlacementID:(NSString*)placementID callback:(void(*)(const char*, const char*))callback {
|
||||
|
||||
if (placementID == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
[ATInterstitialAutoAdManager sharedInstance].delegate = self;
|
||||
|
||||
NSArray *placementIDArray = [self jsonStrToArray:placementID];
|
||||
|
||||
[placementIDArray enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
[self setCallBack:callback forKey:obj];
|
||||
NSLog(@" addAutoLoadAdPlacementID--%@",placementID);
|
||||
}];
|
||||
|
||||
|
||||
[[ATInterstitialAutoAdManager sharedInstance] addAutoLoadAdPlacementIDArray:placementIDArray];
|
||||
}
|
||||
|
||||
-(void) removeAutoLoadAdPlacementID:(NSString*)placementID{
|
||||
NSLog(@" removeAutoLoadAdPlacementID--%@",placementID);
|
||||
|
||||
if (placementID == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSArray *placementIDArray = [self jsonStrToArray:placementID];
|
||||
|
||||
[[ATInterstitialAutoAdManager sharedInstance] removeAutoLoadAdPlacementIDArray:placementIDArray];
|
||||
}
|
||||
|
||||
-(BOOL) autoLoadInterstitialAdReadyForPlacementID:(NSString*)placementID {
|
||||
|
||||
NSLog(@"Unity: autoLoadInterstitialAdReadyForPlacementID--%@---%d",placementID,[[ATInterstitialAutoAdManager sharedInstance] autoLoadInterstitialReadyForPlacementID:placementID]);
|
||||
return [[ATInterstitialAutoAdManager sharedInstance] autoLoadInterstitialReadyForPlacementID:placementID];
|
||||
}
|
||||
|
||||
-(NSString*) getAutoValidAdCaches:(NSString *)placementID{
|
||||
|
||||
NSArray *array = [[ATInterstitialAutoAdManager sharedInstance] checkValidAdCachesWithPlacementID:placementID];
|
||||
|
||||
NSLog(@"Unity: getAutoValidAdCaches::array = %@", array);
|
||||
|
||||
return array.jsonFilterString;
|
||||
}
|
||||
|
||||
-(NSString*) checkAutoAdStatus:(NSString *)placementID {
|
||||
|
||||
ATCheckLoadModel *checkLoadModel = [[ATInterstitialAutoAdManager sharedInstance] checkInterstitialLoadStatusForPlacementID:placementID];
|
||||
|
||||
NSMutableDictionary *statusDict = [NSMutableDictionary dictionary];
|
||||
statusDict[@"isLoading"] = @(checkLoadModel.isLoading);
|
||||
statusDict[@"isReady"] = @(checkLoadModel.isReady);
|
||||
statusDict[@"adInfo"] = checkLoadModel.adOfferInfo;
|
||||
|
||||
NSLog(@":checkAutoAdStatus statusDict = %@", statusDict);
|
||||
return statusDict.jsonFilterString;
|
||||
}
|
||||
|
||||
-(void) setAutoLocalExtra:(NSString*)placementID customDataJSONString:(NSString*)customDataJSONString{
|
||||
|
||||
if ([customDataJSONString isKindOfClass:[NSString class]]) {
|
||||
|
||||
NSDictionary *extraDict = [NSJSONSerialization JSONObjectWithData:[customDataJSONString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
|
||||
NSMutableDictionary *extra = [NSMutableDictionary dictionary];
|
||||
|
||||
if ([extraDict isKindOfClass:[NSDictionary class]]) {
|
||||
|
||||
if (extraDict[kLoadUseRVAsInterstitialKey] != nil) {
|
||||
extra[kATInterstitialExtraUsesRewardedVideo] = @([extraDict[kLoadUseRVAsInterstitialKey] boolValue]);
|
||||
}
|
||||
|
||||
CGFloat scale = [extraDict[kATInterstitialSizeUsesPixelFlagKey] boolValue] ? [UIScreen mainScreen].nativeScale : 1.0f;
|
||||
if ([extraDict[kInterstitialExtraAdSizeKey] isKindOfClass:[NSString class]] && [[extraDict[kInterstitialExtraAdSizeKey] componentsSeparatedByString:@"x"] count] == 2) {
|
||||
NSArray<NSString*>* com = [extraDict[kInterstitialExtraAdSizeKey] componentsSeparatedByString:@"x"];
|
||||
extra[kATInterstitialExtraAdSizeKey] = [NSValue valueWithCGSize:CGSizeMake([com[0] doubleValue] / scale, [com[1] doubleValue] / scale)];
|
||||
}
|
||||
}
|
||||
|
||||
NSLog(@"ATInterstitialAdWrapper::setAutoLocalExtra statusDict = %@", extraDict);
|
||||
[[ATInterstitialAutoAdManager sharedInstance] setLocalExtra:extra placementID:placementID];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
-(void) entryAutoAdScenarioWithPlacementID:(NSString*)placementID scenarioID:(NSString*)scenarioID{
|
||||
NSLog(@"ATInterstitialAdWrapper::entryAutoAdScenarioWithPlacementID = %@ scenarioID = %@", placementID,scenarioID);
|
||||
|
||||
[[ATInterstitialAutoAdManager sharedInstance] entryAdScenarioWithPlacementID:placementID scenarioID:scenarioID];
|
||||
}
|
||||
|
||||
-(void) showAutoInterstitialAd:(NSString*)placementID extraJsonString:(NSString*)extraJsonString {
|
||||
|
||||
NSDictionary *extraDict = ([extraJsonString isKindOfClass:[NSString class]] && [extraJsonString dataUsingEncoding:NSUTF8StringEncoding] != nil) ? [NSJSONSerialization JSONObjectWithData:[extraJsonString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil] : nil;
|
||||
|
||||
NSLog(@"ATInterstitialAdWrapper::showAutoInterstitialAd = %@ extraJsonString = %@", placementID,extraJsonString);
|
||||
|
||||
NSLog(@"ATInterstitialAdWrapper::extraDict = %@", extraDict);
|
||||
|
||||
[[ATInterstitialAutoAdManager sharedInstance] showAutoLoadInterstitialWithPlacementID:placementID scene:extraDict[kATUnityUtilitiesAdShowingExtraScenarioKey] inViewController:[UIApplication sharedApplication].delegate.window.rootViewController delegate:self];
|
||||
}
|
||||
|
||||
#pragma mark - delegate method(s)
|
||||
// ad
|
||||
- (void)didStartLoadingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"startLoadingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFinishLoadingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"finishLoadingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFailToLoadADSourceWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra error:(NSError*)error{
|
||||
[self invokeCallback:@"failToLoadADSource" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
// bidding
|
||||
- (void)didStartBiddingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"startBiddingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFinishBiddingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"finishBiddingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFailBiddingADSourceWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra error:(NSError*)error{
|
||||
[self invokeCallback:@"failBiddingADSource" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(void) didFinishLoadingADWithPlacementID:(NSString *)placementID {
|
||||
[self invokeCallback:@"OnInterstitialAdLoaded" placementID:placementID error:nil extra:nil];
|
||||
}
|
||||
|
||||
-(void) didFailToLoadADWithPlacementID:(NSString*)placementID error:(NSError*)error {
|
||||
error = error != nil ? error : [NSError errorWithDomain:@"com.thinkup.Unity3DPackage" code:100001 userInfo:@{NSLocalizedDescriptionKey:@"AT has failed to load ad", NSLocalizedFailureReasonErrorKey:@"AT has failed to load ad"}];
|
||||
[self invokeCallback:@"OnInterstitialAdLoadFailure" placementID:placementID error:error extra:nil];
|
||||
}
|
||||
|
||||
-(void) interstitialDidShowForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnInterstitialAdShow" placementID:placementID error:nil extra:extra];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kATUnityUtilitiesInterstitialImpressionNotification object:nil];
|
||||
}
|
||||
|
||||
-(void) interstitialFailedToShowForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary *)extra {
|
||||
error = error != nil ? error : [NSError errorWithDomain:@"com.thinkup.Unity3DPackage" code:100001 userInfo:@{NSLocalizedDescriptionKey:@"AT has failed to show ad", NSLocalizedFailureReasonErrorKey:@"AT has failed to show ad"}];
|
||||
[self invokeCallback:@"OnInterstitialAdFailedToShow" placementID:placementID error:error extra:nil];
|
||||
}
|
||||
|
||||
-(void) interstitialDidStartPlayingVideoForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnInterstitialAdVideoPlayStart" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) interstitialDidEndPlayingVideoForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnInterstitialAdVideoPlayEnd" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) interstitialDidFailToPlayVideoForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnInterstitialAdVideoPlayFailure" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
-(void) interstitialDidCloseForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnInterstitialAdClose" placementID:placementID error:nil extra:extra];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kATUnityUtilitiesInterstitialCloseNotification object:nil];
|
||||
}
|
||||
|
||||
-(void) interstitialDidClickForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnInterstitialAdClick" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
@end
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdd7e10786c5e47c88e4def0a081f992
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// ATNativeAdWrapper.h
|
||||
// UnityContainer
|
||||
//
|
||||
// Created by Martin Lau on 27/07/2018.
|
||||
// Copyright © 2018 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ATBaseUnityWrapper.h"
|
||||
#import <AnyThinkNative/ATNativeADDelegate.h>
|
||||
|
||||
extern NSString *const kParsedPropertiesFrameKey;
|
||||
extern NSString *const kParsedPropertiesBackgroundColorKey;
|
||||
extern NSString *const kParsedPropertiesTextColorKey;
|
||||
extern NSString *const kParsedPropertiesTextSizeKey;
|
||||
|
||||
extern NSString *const kNativeAssetAdvertiser;
|
||||
extern NSString *const kNativeAssetText;
|
||||
extern NSString *const kNativeAssetTitle;
|
||||
extern NSString *const kNativeAssetCta;
|
||||
extern NSString *const kNativeAssetRating;
|
||||
extern NSString *const kNativeAssetIcon;
|
||||
extern NSString *const kNativeAssetMainImage;
|
||||
extern NSString *const kNativeAssetSponsorImage;
|
||||
extern NSString *const kNativeAssetDislike;
|
||||
extern NSString *const kNativeAssetMedia;
|
||||
|
||||
extern NSString *kATAdLoadingExtraNativeAdSizeKey;
|
||||
extern NSString *kATNativeAdSizeUsesPixelFlagKey;
|
||||
|
||||
@interface ATNativeAdWrapper : ATBaseUnityWrapper<ATNativeADDelegate>
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40caa23a9d05746b68dc834c60cdfb6c
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,405 @@
|
||||
//
|
||||
// ATNativeAdWrapper.m
|
||||
// UnityContainer
|
||||
//
|
||||
// Created by Martin Lau on 27/07/2018.
|
||||
// Copyright © 2018 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ATNativeAdWrapper.h"
|
||||
#import "ATUnityUtilities.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <AnyThinkNative/ATAdManager+Native.h>
|
||||
#import <AnyThinkNative/ATNativeAdConfiguration.h>
|
||||
#import <AnyThinkNative/ATNativeADView.h>
|
||||
#import "ATAutolayoutCategories.h"
|
||||
#import "ATUnityManager.h"
|
||||
#import "ATNativeSelfRenderView.h"
|
||||
#define kNavigationBarHeight ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown ? ([[UIApplication sharedApplication]statusBarFrame].size.height + 44) : ([[UIApplication sharedApplication]statusBarFrame].size.height - 4))
|
||||
|
||||
#define kScreenW ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown ? UIScreen.mainScreen.bounds.size.width : UIScreen.mainScreen.bounds.size.height)
|
||||
|
||||
NSString *const kParsedPropertiesFrameKey = @"frame";
|
||||
NSString *const kParsedPropertiesBackgroundColorKey = @"background_color";
|
||||
NSString *const kParsedPropertiesTextColorKey = @"text_color";
|
||||
NSString *const kParsedPropertiesTextSizeKey = @"text_size";
|
||||
|
||||
NSString *const kNativeAssetAdvertiser = @"advertiser_label";
|
||||
NSString *const kNativeAssetText = @"text";
|
||||
NSString *const kNativeAssetTitle = @"title";
|
||||
NSString *const kNativeAssetCta = @"cta";
|
||||
NSString *const kNativeAssetRating = @"rating";
|
||||
NSString *const kNativeAssetIcon = @"icon";
|
||||
NSString *const kNativeAssetMainImage = @"main_image";
|
||||
NSString *const kNativeAssetSponsorImage = @"sponsor_image";
|
||||
NSString *const kNativeAssetDislike = @"dislike_button";
|
||||
NSString *const kNativeAssetMedia = @"media";
|
||||
|
||||
NSString *kATAdLoadingExtraNativeAdSizeKey = @"native_ad_size";
|
||||
NSString *kATNativeAdSizeUsesPixelFlagKey = @"uses_pixel";
|
||||
|
||||
NSDictionary* at_parseUnityProperties(NSDictionary *properties) {
|
||||
NSMutableDictionary *result = NSMutableDictionary.dictionary;
|
||||
CGFloat scale = [properties[@"usesPixel"] boolValue] ? [UIScreen mainScreen].nativeScale : 1.0f;
|
||||
result[kParsedPropertiesFrameKey] = [NSString stringWithFormat:@"{{%@, %@}, {%@, %@}}", @([properties[@"x"] doubleValue] / scale), @([properties[@"y"] doubleValue] / scale), @([properties[@"width"] doubleValue] / scale), @([properties[@"height"] doubleValue] / scale)];
|
||||
result[kParsedPropertiesBackgroundColorKey] = properties[@"backgroundColor"];
|
||||
result[kParsedPropertiesTextColorKey] = properties[@"textColor"];
|
||||
result[kParsedPropertiesTextSizeKey] = properties[@"textSize"];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NSDictionary* at_parseUnityMetrics(NSDictionary* metrics) {
|
||||
NSMutableDictionary *result = NSMutableDictionary.dictionary;
|
||||
NSDictionary *keysMap = @{@"appIcon":kNativeAssetIcon, @"mainImage":kNativeAssetMainImage, @"title":kNativeAssetTitle, @"desc":kNativeAssetText, @"adLogo":kNativeAssetSponsorImage, @"cta":kNativeAssetCta, @"dislike":kNativeAssetDislike};
|
||||
[keysMap enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { result[keysMap[key]] = at_parseUnityProperties(metrics[key]); }];
|
||||
return result;
|
||||
}
|
||||
|
||||
#define CS_ATNativeAdWrapper "ATNativeAdWrapper"
|
||||
|
||||
NSString *const kATNativeAdAdaptiveHeightKey = @"AdaptiveHeight";
|
||||
|
||||
@interface ATNativeAdWrapper()
|
||||
@property(nonatomic, strong) ATNativeSelfRenderView *nativeSelfRenderView;
|
||||
@property(nonatomic, strong) ATNativeADView *adView;
|
||||
@property(nonatomic, readonly) NSMutableDictionary<NSString*, UIView*> *viewsStorage;
|
||||
@end
|
||||
@implementation ATNativeAdWrapper
|
||||
+(instancetype)sharedInstance {
|
||||
static ATNativeAdWrapper *sharedInstance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [[ATNativeAdWrapper alloc] init];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
-(instancetype) init {
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_viewsStorage = [NSMutableDictionary<NSString*, UIView*> dictionary];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
UIEdgeInsets SafeAreaInsets_ATUnityNative() {
|
||||
return ([[UIApplication sharedApplication].keyWindow respondsToSelector:@selector(safeAreaInsets)] ? [UIApplication sharedApplication].keyWindow.safeAreaInsets : UIEdgeInsetsZero);
|
||||
}
|
||||
|
||||
- (id)selWrapperClassWithDict:(NSDictionary *)dict callback:(void(*)(const char*, const char*))callback {
|
||||
NSString *selector = dict[@"selector"];
|
||||
NSArray<NSString*>* arguments = dict[@"arguments"];
|
||||
NSString *firstObject = @"";
|
||||
NSString *secondObject = @"";
|
||||
NSString *lastObject = @"";
|
||||
if (![ATUnityUtilities isEmpty:arguments]) {
|
||||
for (int i = 0; i < arguments.count; i++) {
|
||||
if (i == 0) { firstObject = arguments[i]; }
|
||||
else if (i == 1) { secondObject = arguments[i]; }
|
||||
else { lastObject = arguments[i]; }
|
||||
}
|
||||
}
|
||||
|
||||
if ([selector isEqualToString:@"loadNativeAdWithPlacementID:customDataJSONString:callback:"]) {
|
||||
[self loadNativeAdWithPlacementID:firstObject customDataJSONString:secondObject callback:callback];
|
||||
} else if ([selector isEqualToString:@"isNativeAdReadyForPlacementID:"]) {
|
||||
return [NSNumber numberWithBool:[self isNativeAdReadyForPlacementID:firstObject]];
|
||||
} else if ([selector isEqualToString:@"showNativeAdWithPlacementID:metricsJSONString:extraJsonString:"]) {
|
||||
[self showNativeAdWithPlacementID:firstObject metricsJSONString:secondObject extraJsonString:lastObject];
|
||||
} else if ([selector isEqualToString:@"removeNativeAdViewWithPlacementID:"]) {
|
||||
[self removeNativeAdViewWithPlacementID:firstObject];
|
||||
} else if ([selector isEqualToString:@"checkAdStatus:"]) {
|
||||
return [self checkAdStatus:firstObject];
|
||||
} else if ([selector isEqualToString:@"clearCache"]) {
|
||||
[self clearCache];
|
||||
} else if ([selector isEqualToString:@"getValidAdCaches:"]) {
|
||||
return [self getValidAdCaches:firstObject];
|
||||
}else if ([selector isEqualToString:@"entryScenarioWithPlacementID:scenarioID:"]) {
|
||||
[self entryScenarioWithPlacementID:firstObject scenarioID:secondObject];
|
||||
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(void) loadNativeAdWithPlacementID:(NSString*)placementID customDataJSONString:(NSString*)customDataJSONString callback:(void(*)(const char*, const char *))callback {
|
||||
[self setCallBack:callback forKey:placementID];
|
||||
NSMutableDictionary *extra = [NSMutableDictionary dictionaryWithDictionary:@{kATExtraInfoNativeAdTypeKey:@(ATGDTNativeAdTypeSelfRendering), kATExtraNativeImageSizeKey:kATExtraNativeImageSize690_388}];
|
||||
if ([customDataJSONString isKindOfClass:[NSString class]] && [customDataJSONString length] > 0) {
|
||||
NSDictionary *extraDict = [NSJSONSerialization JSONObjectWithData:[customDataJSONString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
NSLog(@"extraDict = %@", extraDict);
|
||||
CGFloat scale = [extraDict[kATNativeAdSizeUsesPixelFlagKey] boolValue] ? [UIScreen mainScreen].nativeScale : 1.0f;
|
||||
if ([extraDict[kATAdLoadingExtraNativeAdSizeKey] isKindOfClass:[NSString class]] && [[extraDict[kATAdLoadingExtraNativeAdSizeKey] componentsSeparatedByString:@"x"] count] == 2) {
|
||||
NSArray<NSString*>* com = [extraDict[kATAdLoadingExtraNativeAdSizeKey] componentsSeparatedByString:@"x"];
|
||||
extra[kATExtraInfoNativeAdSizeKey] = [NSValue valueWithCGSize:CGSizeMake([com[0] doubleValue] / scale, [com[1] doubleValue] / scale)];
|
||||
}
|
||||
}
|
||||
NSLog(@"extra = %@", extra);
|
||||
[[ATAdManager sharedManager] loadADWithPlacementID:placementID extra:extra delegate:self];
|
||||
}
|
||||
|
||||
-(BOOL) isNativeAdReadyForPlacementID:(NSString*)placementID {
|
||||
return [[ATAdManager sharedManager] nativeAdReadyForPlacementID:placementID];
|
||||
}
|
||||
|
||||
-(NSString*) checkAdStatus:(NSString *)placementID {
|
||||
ATCheckLoadModel *checkLoadModel = [[ATAdManager sharedManager] checkNativeLoadStatusForPlacementID:placementID];
|
||||
NSMutableDictionary *statusDict = [NSMutableDictionary dictionary];
|
||||
statusDict[@"isLoading"] = @(checkLoadModel.isLoading);
|
||||
statusDict[@"isReady"] = @(checkLoadModel.isReady);
|
||||
statusDict[@"adInfo"] = checkLoadModel.adOfferInfo;
|
||||
NSLog(@"ATNativeAdWrapper::statusDict = %@", statusDict);
|
||||
return statusDict.jsonFilterString;
|
||||
}
|
||||
- (void)entryScenarioWithPlacementID:(NSString *)placementID scenarioID:(NSString *)scenarioID{
|
||||
|
||||
[[ATAdManager sharedManager] entryNativeScenarioWithPlacementID:placementID scene:scenarioID];
|
||||
}
|
||||
|
||||
-(NSString*) getValidAdCaches:(NSString *)placementID {
|
||||
NSArray *array = [[ATAdManager sharedManager] getNativeValidAdsForPlacementID:placementID];
|
||||
NSLog(@"ATNativeAdWrapper::array = %@", array);
|
||||
return array.jsonFilterString;
|
||||
}
|
||||
|
||||
-(void) showNativeAdWithPlacementID:(NSString*)placementID metricsJSONString:(NSString*)metricsJSONString extraJsonString:(NSString*)extraJsonString {
|
||||
|
||||
if (self.adView) {
|
||||
[self.adView removeFromSuperview];
|
||||
self.adView = nil;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ([self isNativeAdReadyForPlacementID:placementID]) {
|
||||
NSDictionary *metrics = [NSJSONSerialization JSONObjectWithData:[metricsJSONString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
NSDictionary *extraDict = ([extraJsonString isKindOfClass:[NSString class]] && [extraJsonString dataUsingEncoding:NSUTF8StringEncoding] != nil) ? [NSJSONSerialization JSONObjectWithData:[extraJsonString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil] : nil;
|
||||
|
||||
NSDictionary *parsedMetrics = at_parseUnityMetrics(metrics);
|
||||
NSLog(@"metrics = %@, parsedMetrics = %@", metrics, parsedMetrics);
|
||||
NSLog(@"ATNativeAdWrapper::extraDict:%@",extraDict);
|
||||
|
||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[button addTarget:self action:@selector(noop) forControlEvents:UIControlEventTouchUpInside];
|
||||
button.frame = CGRectFromString(at_parseUnityProperties(metrics[@"parent"])[kParsedPropertiesFrameKey]);
|
||||
|
||||
CGRect adViewFrame = CGRectFromString(at_parseUnityProperties(metrics[@"parent"])[kParsedPropertiesFrameKey]);
|
||||
CGRect mediaViewFrame = CGRectFromString(parsedMetrics[kNativeAssetMainImage][kParsedPropertiesFrameKey]);
|
||||
CGRect logoFrame = CGRectFromString(parsedMetrics[kNativeAssetSponsorImage][kParsedPropertiesFrameKey]);
|
||||
ATNativeADConfiguration *configuration = [ATNativeADConfiguration new];
|
||||
configuration.ADFrame = CGRectMake(0, 0, CGRectGetWidth(adViewFrame), CGRectGetHeight(adViewFrame));
|
||||
configuration.mediaViewFrame = mediaViewFrame;
|
||||
configuration.logoViewFrame = logoFrame;
|
||||
|
||||
configuration.delegate = self;
|
||||
if (extraDict[kATNativeAdAdaptiveHeightKey] != nil) {
|
||||
configuration.sizeToFit = [extraDict[kATNativeAdAdaptiveHeightKey] boolValue];
|
||||
}
|
||||
configuration.rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
|
||||
configuration.context = @{
|
||||
kATNativeAdConfigurationContextAdOptionsViewFrameKey:[NSValue valueWithCGRect:CGRectMake(CGRectGetWidth([UIScreen mainScreen].bounds) - 43.0f, .0f, 43.0f, 18.0f)],
|
||||
kATNativeAdConfigurationContextAdLogoViewFrameKey:[NSValue valueWithCGRect:CGRectMake(.0f, .0f, 54.0f, 18.0f)],
|
||||
kATNativeAdConfigurationContextNetworkLogoViewFrameKey:[NSValue valueWithCGRect:CGRectMake(CGRectGetWidth(configuration.ADFrame) - 54.0f, CGRectGetHeight(configuration.ADFrame) - 18.0f, 54.0f, 18.0f)]
|
||||
};
|
||||
|
||||
ATNativeAdOffer *offer = [[ATAdManager sharedManager] getNativeAdOfferWithPlacementID:placementID scene:extraDict[kATUnityUtilitiesAdShowingExtraScenarioKey]];
|
||||
|
||||
ATNativeSelfRenderView *selfRenderView = [self getSelfRenderViewOffer:offer withMetrics:parsedMetrics];
|
||||
|
||||
selfRenderView.backgroundColor = [UIColor colorWithHexString:parsedMetrics[kNativeAssetMainImage][@"background_color"]];
|
||||
|
||||
ATNativeADView *adview = [self getNativeADView:configuration offer:offer selfRenderView:selfRenderView withPlacementId:placementID];
|
||||
[self prepareWithNativePrepareInfo:selfRenderView nativeADView:adview];
|
||||
[offer rendererWithConfiguration:configuration selfRenderView:selfRenderView nativeADView:adview];
|
||||
// 是否隐藏内部渲染logoView
|
||||
if (logoFrame.size.width == 0 || logoFrame.size.height == 0) {
|
||||
adview.logoImageView.hidden = YES;
|
||||
}
|
||||
adview.ctaLabel.hidden = [adview.nativeAd.ctaText length] == 0;
|
||||
if (adview != nil) {
|
||||
[self removeNativeAdViewWithPlacementID:placementID];
|
||||
|
||||
_viewsStorage[placementID] = button;
|
||||
|
||||
[button addSubview:adview];
|
||||
|
||||
[[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:button];
|
||||
|
||||
NSString *position = extraDict[@"Position"];
|
||||
CGSize totalSize = [UIApplication sharedApplication].keyWindow.rootViewController.view.bounds.size;
|
||||
UIEdgeInsets safeAreaInsets = SafeAreaInsets_ATUnityNative();
|
||||
|
||||
if ([@"Top" isEqualToString:position]) {
|
||||
button.frame = CGRectMake((totalSize.width - CGRectGetWidth(adview.bounds)) / 2.0f, safeAreaInsets.top , CGRectGetWidth(adview.bounds), CGRectGetHeight(adview.bounds));
|
||||
} else if ([@"Bottom" isEqualToString:position]) {
|
||||
button.frame = CGRectMake((totalSize.width - CGRectGetWidth(adview.bounds)) / 2.0f, totalSize.height - safeAreaInsets.bottom - CGRectGetHeight(adview.bounds) , CGRectGetWidth(adview.bounds), CGRectGetHeight(adview.bounds));
|
||||
} else {
|
||||
button.frame = CGRectFromString(at_parseUnityProperties(metrics[@"parent"])[kParsedPropertiesFrameKey]);
|
||||
}
|
||||
|
||||
NSMutableDictionary *contextStorage = [NSMutableDictionary dictionary];
|
||||
[contextStorage setValue:button forKey:@"button"];
|
||||
[contextStorage setValue:position forKey:@"position"];
|
||||
[adview addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:(void*)CFBridgingRetain(contextStorage)];
|
||||
}
|
||||
}
|
||||
}
|
||||
- (void)prepareWithNativePrepareInfo:(ATNativeSelfRenderView *)selfRenderView nativeADView:(ATNativeADView *)nativeADView{
|
||||
|
||||
ATNativePrepareInfo *info = [ATNativePrepareInfo loadPrepareInfo:^(ATNativePrepareInfo * _Nonnull prepareInfo) {
|
||||
prepareInfo.textLabel = selfRenderView.textLabel;
|
||||
prepareInfo.advertiserLabel = selfRenderView.advertiserLabel;
|
||||
prepareInfo.titleLabel = selfRenderView.titleLabel;
|
||||
prepareInfo.ratingLabel = selfRenderView.ratingLabel;
|
||||
prepareInfo.iconImageView = selfRenderView.iconImageView;
|
||||
prepareInfo.mainImageView = selfRenderView.mainImageView;
|
||||
prepareInfo.dislikeButton = selfRenderView.dislikeButton;
|
||||
prepareInfo.ctaLabel = selfRenderView.ctaLabel;
|
||||
prepareInfo.mediaView = selfRenderView.mediaView;
|
||||
}];
|
||||
[nativeADView prepareWithNativePrepareInfo:info];
|
||||
[nativeADView addSubview:selfRenderView];
|
||||
selfRenderView.frame = CGRectMake(0, 0, CGRectGetWidth(nativeADView.frame), CGRectGetHeight(nativeADView.frame));
|
||||
}
|
||||
|
||||
|
||||
- (ATNativeSelfRenderView *)getSelfRenderViewOffer:(ATNativeAdOffer *)offer withMetrics:(NSDictionary*)metrics{
|
||||
|
||||
ATNativeSelfRenderView *selfRenderView = [[ATNativeSelfRenderView alloc]initWithOffer:offer];
|
||||
|
||||
self.nativeSelfRenderView = selfRenderView;
|
||||
|
||||
[selfRenderView configureMetrics:metrics];
|
||||
|
||||
|
||||
return selfRenderView;
|
||||
}
|
||||
|
||||
|
||||
- (ATNativeADView *)getNativeADView:(ATNativeADConfiguration *)config offer:(ATNativeAdOffer *)offer selfRenderView:(ATNativeSelfRenderView *)selfRenderView withPlacementId:(NSString*)placementID{
|
||||
|
||||
ATNativeADView *nativeADView = [[ATNativeADView alloc]initWithConfiguration:config currentOffer:offer placementID:placementID];
|
||||
|
||||
|
||||
|
||||
UIView *mediaView = [nativeADView getMediaView];
|
||||
|
||||
NSMutableArray *array = [@[selfRenderView.iconImageView,selfRenderView.titleLabel,selfRenderView.textLabel,selfRenderView.ctaLabel,selfRenderView.mainImageView] mutableCopy];
|
||||
|
||||
if (mediaView && offer.nativeAd.isVideoContents) {
|
||||
[array addObject:mediaView];
|
||||
|
||||
selfRenderView.mediaView = mediaView;
|
||||
[selfRenderView addSubview:mediaView];
|
||||
}
|
||||
|
||||
[nativeADView registerClickableViewArray:array];
|
||||
|
||||
|
||||
|
||||
self.adView = nativeADView;
|
||||
|
||||
return nativeADView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(void) noop {
|
||||
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
|
||||
if ([keyPath isEqualToString:@"frame"]) {
|
||||
CGRect frame = [change[@"new"] CGRectValue];
|
||||
NSDictionary *contextDict = (__bridge NSDictionary*)context;
|
||||
|
||||
CGSize totalSize = [UIApplication sharedApplication].keyWindow.rootViewController.view.bounds.size;
|
||||
UIEdgeInsets safeAreaInsets = SafeAreaInsets_ATUnityNative();
|
||||
NSString *position = contextDict[@"position"];
|
||||
UIButton *button = contextDict[@"button"];
|
||||
CGRect buttonFrame = button.frame;
|
||||
buttonFrame.size.height = frame.size.height;
|
||||
|
||||
if ([position isEqualToString:@"Bottom"]) {
|
||||
buttonFrame.origin.y = totalSize.height - safeAreaInsets.bottom - frame.size.height;
|
||||
}
|
||||
button.frame = buttonFrame;
|
||||
[object removeObserver:self forKeyPath:@"frame"];
|
||||
CFBridgingRelease(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(void) removeNativeAdViewWithPlacementID:(NSString*)placementID {
|
||||
if ([_viewsStorage.allKeys containsObject:placementID]) {
|
||||
[_viewsStorage[placementID] removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) clearCache {
|
||||
|
||||
}
|
||||
|
||||
-(NSString*) scriptWrapperClass {
|
||||
return @"ATNativeAdWrapper";
|
||||
}
|
||||
#pragma mark - delegate
|
||||
-(void) didFinishLoadingADWithPlacementID:(NSString *)placementID {
|
||||
[self invokeCallback:@"OnNativeAdLoaded" placementID:placementID error:nil extra:nil];
|
||||
}
|
||||
|
||||
-(void) didFailToLoadADWithPlacementID:(NSString*)placementID error:(NSError*)error {
|
||||
[self invokeCallback:@"OnNativeAdLoadingFailure" placementID:placementID error:error extra:nil];
|
||||
}
|
||||
// ad
|
||||
- (void)didStartLoadingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"startLoadingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFinishLoadingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"finishLoadingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFailToLoadADSourceWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra error:(NSError*)error{
|
||||
[self invokeCallback:@"failToLoadADSource" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
// bidding
|
||||
- (void)didStartBiddingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"startBiddingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFinishBiddingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"finishBiddingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFailBiddingADSourceWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra error:(NSError*)error{
|
||||
[self invokeCallback:@"failBiddingADSource" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
|
||||
-(void) didShowNativeAdInAdView:(ATNativeADView*)adView placementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnNaitveAdShow" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) didClickNativeAdInAdView:(ATNativeADView*)adView placementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
//Drop ad view
|
||||
[self invokeCallback:@"OnNativeAdClick" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) didTapCloseButtonInAdView:(ATNativeADView*)adView placementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnNativeAdCloseButtonClick" placementID:placementID error:nil extra:extra];
|
||||
[self.adView removeFromSuperview];
|
||||
}
|
||||
|
||||
-(void) didStartPlayingVideoInAdView:(ATNativeADView*)adView placementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
//Drop ad view
|
||||
[self invokeCallback:@"OnNativeAdVideoStart" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) didEndPlayingVideoInAdView:(ATNativeADView*)adView placementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
//Drop ad view
|
||||
[self invokeCallback:@"OnNativeAdVideoEnd" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 261ab4f0b994d412398879c1c1faa933
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// ATNativeSelfRenderView.h
|
||||
// AnyThinkSDKDemo
|
||||
//
|
||||
// Created by GUO PENG on 2022/5/7.
|
||||
// Copyright © 2022 AnyThink. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <AnyThinkNative/AnyThinkNative.h>
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface ATNativeSelfRenderView : UIView
|
||||
|
||||
@property(nonatomic, strong) UILabel *advertiserLabel;
|
||||
@property(nonatomic, strong) UILabel *textLabel;
|
||||
@property(nonatomic, strong) UILabel *titleLabel;
|
||||
@property(nonatomic, strong) UILabel *ctaLabel;
|
||||
@property(nonatomic, strong) UILabel *ratingLabel;
|
||||
@property(nonatomic, strong) UIImageView *iconImageView;
|
||||
@property(nonatomic, strong) UIImageView *mainImageView;
|
||||
@property(nonatomic, strong) UIImageView *sponsorImageView;
|
||||
@property(nonatomic, strong) UIButton *dislikeButton;
|
||||
|
||||
@property(nonatomic, strong) UIView *mediaView;
|
||||
|
||||
-(void) configureMetrics:(NSDictionary *)metrics;
|
||||
- (instancetype) initWithOffer:(ATNativeAdOffer *)offer;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f4f522e679fd46089024575ee66ccac
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,181 @@
|
||||
//
|
||||
// ATNativeSelfRenderView.m
|
||||
// AnyThinkSDKDemo
|
||||
//
|
||||
// Created by GUO PENG on 2022/5/7.
|
||||
// Copyright © 2022 AnyThink. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ATNativeSelfRenderView.h"
|
||||
#import <AnyThinkSDK/ATImageLoader.h>
|
||||
#import "ATNativeAdWrapper.h"
|
||||
#import "ATAutolayoutCategories.h"
|
||||
#import "ATUnityUtilities.h"
|
||||
#define random(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)/255.0]
|
||||
|
||||
#define randomColor random(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))
|
||||
|
||||
@interface ATNativeSelfRenderView()
|
||||
|
||||
@property(nonatomic, strong) ATNativeAdOffer *nativeAdOffer;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation ATNativeSelfRenderView
|
||||
|
||||
- (void)dealloc{
|
||||
NSLog(@"🔥---ATNativeSelfRenderView--销毁");
|
||||
}
|
||||
|
||||
- (instancetype) initWithOffer:(ATNativeAdOffer *)offer{
|
||||
|
||||
if (self = [super init]) {
|
||||
|
||||
_nativeAdOffer = offer;
|
||||
|
||||
[self addView];
|
||||
[self makeConstraintsForSubviews];
|
||||
|
||||
[self setupUI];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)addView{
|
||||
|
||||
self.advertiserLabel = [[UILabel alloc]init];
|
||||
self.advertiserLabel.font = [UIFont boldSystemFontOfSize:15.0f];
|
||||
self.advertiserLabel.textColor = [UIColor blackColor];
|
||||
self.advertiserLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.advertiserLabel.userInteractionEnabled = YES;
|
||||
self.advertiserLabel.translatesAutoresizingMaskIntoConstraints = false;
|
||||
[self addSubview:self.advertiserLabel];
|
||||
|
||||
self.titleLabel = [[UILabel alloc]init];
|
||||
self.titleLabel.font = [UIFont boldSystemFontOfSize:18.0f];
|
||||
self.titleLabel.textColor = [UIColor blackColor];
|
||||
self.titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.titleLabel.userInteractionEnabled = YES;
|
||||
self.titleLabel.translatesAutoresizingMaskIntoConstraints = false;
|
||||
[self addSubview:self.titleLabel];
|
||||
|
||||
self.textLabel = [[UILabel alloc]init];
|
||||
self.textLabel.font = [UIFont systemFontOfSize:15.0f];
|
||||
self.textLabel.textColor = [UIColor blackColor];
|
||||
self.textLabel.userInteractionEnabled = YES;
|
||||
self.textLabel.numberOfLines = 0;
|
||||
self.textLabel.translatesAutoresizingMaskIntoConstraints = false;
|
||||
[self addSubview:self.textLabel];
|
||||
|
||||
self.ctaLabel = [[UILabel alloc]init];
|
||||
self.ctaLabel.font = [UIFont systemFontOfSize:15.0f];
|
||||
self.ctaLabel.textColor = [UIColor blackColor];
|
||||
self.ctaLabel.userInteractionEnabled = YES;
|
||||
self.ctaLabel.translatesAutoresizingMaskIntoConstraints = false;
|
||||
[self addSubview:self.ctaLabel];
|
||||
|
||||
self.ratingLabel = [[UILabel alloc]init];
|
||||
self.ratingLabel.font = [UIFont systemFontOfSize:15.0f];
|
||||
self.ratingLabel.textColor = [UIColor blackColor];
|
||||
self.ratingLabel.userInteractionEnabled = YES;
|
||||
self.ratingLabel.translatesAutoresizingMaskIntoConstraints = false;
|
||||
[self addSubview:self.ratingLabel];
|
||||
|
||||
self.iconImageView = [[UIImageView alloc]init];
|
||||
self.iconImageView.layer.cornerRadius = 4.0f;
|
||||
self.iconImageView.layer.masksToBounds = YES;
|
||||
self.iconImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
self.iconImageView.translatesAutoresizingMaskIntoConstraints = false;
|
||||
self.iconImageView.userInteractionEnabled = YES;
|
||||
[self addSubview:self.iconImageView];
|
||||
|
||||
|
||||
self.mainImageView = [[UIImageView alloc]init];
|
||||
self.mainImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
self.mainImageView.userInteractionEnabled = YES;
|
||||
self.mainImageView.translatesAutoresizingMaskIntoConstraints = false;
|
||||
[self addSubview:self.mainImageView];
|
||||
|
||||
self.dislikeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
self.dislikeButton.translatesAutoresizingMaskIntoConstraints = false;
|
||||
self.dislikeButton.backgroundColor = [UIColor whiteColor];
|
||||
[self.dislikeButton setImage:[self getCloseImage] forState:0];
|
||||
[self addSubview:self.dislikeButton];
|
||||
}
|
||||
|
||||
|
||||
- (UIImage *)getCloseImage {
|
||||
|
||||
NSString *imageBase64String = @"iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAAAXNSR0IArs4c6QAAAIRlWElmTU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAABIAAAAAQAAAEgAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAAEigAwAEAAAAAQAAAEgAAAAAYwsr7AAAAAlwSFlzAAALEwAACxMBAJqcGAAAABxpRE9UAAAAAgAAAAAAAAAkAAAAKAAAACQAAAAkAAACiSuooU0AAAJVSURBVHgB5JqhbsMwEECLisqGhldYNNaxqlJRP2CoY8Wjo/ub4UllI5VGy8f6ASMBA0XbvWiuXKtpnOQcO+lJJ8eRY989351dqYNBuzKU5W5EJ6IPogvRx39dS2ureb+U94zlm1vR3glQcA5Hn0RtCHWfmetOdCTaSbGh1IXg+52B1QlQgLkX1YoUX0iMIyVZO8moignGhWhACas0hMKJUa6hsfvYRJ2KJkTNVDQ2iLL1sRFbWxXyPMWoKYKFra3VJlIqRhEuct73PTYHT7mJLOJrUKrj8CGIcISm6nRVu/BFVfoQOS5EtUgib93J+9KnnjaSkXzdxYLsu4H4ho+1ZChfdeko94XijsNHfK0sXbgEus7W7eNrJelz3SmCWKkeXUNquaC8U61P9x0XQlm/9H5ERb/G6DHgONWGl4qRSvRsNpv3/X7/tdvtPufz+YssaAxQb99ElNe6GEWNowc4v5ZkWfYdCtK5tRQ2ozCKVE4udtPikz+GgOTCMWvOZjONiD37M2SpQH+93W4/jLF2qwmpCA5raPggc8DiREbSU6kP4/H4GUNtOOZZA1IRnMPh8LNarV61/JB5Toq1SnoZ46g5ISC1CIdgmYgehZBSiSAzjzakluHA4iTNVOFoQ4oABx7H04zfIEEAMW/TSIoEx/DgfwR5rpkXQdq6kCLDgUVeh6bsdGitCikBODCBTV6MggNiA3whJQIHJgsANf55gfO+Wgap6KIZ4J7jYzNs2gUEyEuQzKXSbiPBAWAOyIek+hhfSBHhGJ/904Pd19QySAnAWf8BAAD///Z/hqsAAAJUSURBVOWaoVLDQBCGT6HqUGgqq3CVnc5U9QFQwVVja3mMGjSamTpMXwBbXB8AU4Gogv1DfyYtuSS929xd2p25WSYkd/992d3bMBhjzCzmWK1Wb98W2263n+PxeB5Tn6wdD9ByuXy1sPm7nAAkcx8DUhM4pBQREtiEB2SDs9vtvgCDYIo+EqQpAE1kBKtDVXCyLHtCzUkIUg5oGApQHRzqSAgS2JgBhbXpm8KhhkQggY25pqi2/KlwqCMBSDeixVzJeKAobe8KhzoiQxIZv4ZipF6ofeFQUyRIeYHe89GvQ1pwIkK6JRx4pJlaBGnDobbAkdQDmKKppNlisXguNnj8GU0g+hxZ0OtFVEHabDYfvvPvnz9IL0IaaEwOkYRCrwWH+qogjUajOe/z8AfpJfPkhjTzPs3W6/U7wcBrwxGNeQTaIPX7/Ufe4+jz7y95ttTu5KpaCrQFhxqLkLDWixh/5+HBwGoqUSSzzxDqCm+z0ctSXAvR8684H9PyjiIA6uiojB6CQhRF+RtRZKiVtYdw6PEN0tUocNVdenIRSJkfXhAk7PVku5RUQ2phr06Giu7dG8kcrmHf9nPYW+2pVUfunOvRyXXHBkvlMySxSMKeVO2c+qNG/Y4LvXOIJPXIOQaJvO1i4YZm1NMg1pNVutRtQys0BzX0Dl1oJqHRuc/RIIqUSzGaoClYSjUBiZMhBVCoNdASNWpswJDnsUAlDaYMGFJvKqPtzwWsMZCRZMSIrlpDVGnCQqR0HkoVNRROvHGcLtgo6lZZ7eL1yf5ePIP/IwgaKT805vxmzF7SHAAAAABJRU5ErkJggg==";
|
||||
|
||||
UIImage *closeImage = [UIImage imageWithData:[[NSData alloc] initWithBase64EncodedString:imageBase64String options:NSDataBase64DecodingIgnoreUnknownCharacters]];
|
||||
NSLog(@"getCloseImage--%@",closeImage);
|
||||
return closeImage;
|
||||
}
|
||||
|
||||
|
||||
- (void)setupUI{
|
||||
|
||||
if (self.nativeAdOffer.nativeAd.icon) {
|
||||
self.iconImageView.image = self.nativeAdOffer.nativeAd.icon;
|
||||
}
|
||||
[[ATImageLoader shareLoader]loadImageWithURL:[NSURL URLWithString:self.nativeAdOffer.nativeAd.iconUrl] completion:^(UIImage *image, NSError *error) {
|
||||
|
||||
if (!error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.iconImageView setImage:image];
|
||||
});
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
NSLog(@"🔥----iconUrl:%@",self.nativeAdOffer.nativeAd.iconUrl);
|
||||
|
||||
[[ATImageLoader shareLoader]loadImageWithURL:[NSURL URLWithString:self.nativeAdOffer.nativeAd.imageUrl] completion:^(UIImage *image, NSError *error) {
|
||||
|
||||
if (!error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.mainImageView setImage:image];
|
||||
});
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
NSLog(@"🔥----imageUrl:%@",self.nativeAdOffer.nativeAd.imageUrl);
|
||||
|
||||
self.advertiserLabel.text = self.nativeAdOffer.nativeAd.advertiser;
|
||||
|
||||
|
||||
self.titleLabel.text = self.nativeAdOffer.nativeAd.title;
|
||||
|
||||
self.textLabel.text = self.nativeAdOffer.nativeAd.mainText;
|
||||
|
||||
self.ctaLabel.text = self.nativeAdOffer.nativeAd.ctaText;
|
||||
|
||||
self.ratingLabel.text = [NSString stringWithFormat:@"%@", self.nativeAdOffer.nativeAd.rating ? self.nativeAdOffer.nativeAd.rating : @""];
|
||||
}
|
||||
|
||||
-(void) makeConstraintsForSubviews {
|
||||
|
||||
self.backgroundColor = [UIColor clearColor];// randomColor;
|
||||
|
||||
self.titleLabel.backgroundColor = [UIColor clearColor];
|
||||
|
||||
self.textLabel.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
-(void) configureMetrics:(NSDictionary *)metrics {
|
||||
|
||||
NSDictionary<NSString*, UIView*> *views = @{kNativeAssetTitle:_titleLabel, kNativeAssetText:_textLabel, kNativeAssetCta:_ctaLabel, kNativeAssetRating:_ratingLabel, kNativeAssetAdvertiser:_advertiserLabel, kNativeAssetIcon:_iconImageView, kNativeAssetMainImage:_mainImageView, kNativeAssetDislike:_dislikeButton};
|
||||
[views enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
|
||||
CGRect frame = CGRectFromString(metrics[key][kParsedPropertiesFrameKey]);
|
||||
[self addConstraintsWithVisualFormat:[NSString stringWithFormat:@"|-x-[%@(w)]", key] options:0 metrics:@{@"x":@(frame.origin.x), @"w":@(frame.size.width)} views:views];
|
||||
[self addConstraintsWithVisualFormat:[NSString stringWithFormat:@"V:|-y-[%@(h)]", key] options:0 metrics:@{@"y":@(frame.origin.y), @"h":@(frame.size.height)} views:views];
|
||||
if ([obj respondsToSelector:@selector(setBackgroundColor:)] && [metrics[key] containsObjectForKey:@"background_color"]) [obj setBackgroundColor:[metrics[key][@"background_color"] hasPrefix:@"#"] ? [UIColor colorWithHexString:metrics[key][@"background_color"]] : [UIColor clearColor]];
|
||||
if ([obj respondsToSelector:@selector(setTextColor:)] && [metrics[key] containsObjectForKey:@"text_color"]) [obj setTextColor:[UIColor colorWithHexString:metrics[key][@"text_color"]]];
|
||||
if ([obj respondsToSelector:@selector(setFont:)] && [metrics[key] containsObjectForKey:@"text_size"] && [metrics[key][@"text_size"] respondsToSelector:@selector(doubleValue)]) [obj setFont:[UIFont systemFontOfSize:[metrics[key][@"text_size"] doubleValue]]];
|
||||
}];
|
||||
if ([metrics containsObjectForKey:kNativeAssetMedia]) self.mediaView.frame = CGRectFromString(metrics[kNativeAssetMedia][kParsedPropertiesFrameKey]);
|
||||
else self.mediaView.frame = CGRectFromString(metrics[kNativeAssetMainImage][kParsedPropertiesFrameKey]);
|
||||
}
|
||||
@end
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df5905d84b7e24fe5ba1abd20cd5f4a8
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// ATRewardedVideoWrapper.h
|
||||
// UnityContainer
|
||||
//
|
||||
// Created by Martin Lau on 08/08/2018.
|
||||
// Copyright © 2018 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ATBaseUnityWrapper.h"
|
||||
|
||||
@interface ATRewardedVideoWrapper : ATBaseUnityWrapper
|
||||
@end
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4921d595c3e5146fb90e228e1c5f02f4
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,326 @@
|
||||
//
|
||||
// ATRewardedVideoWrapper.m
|
||||
// UnityContainer
|
||||
//
|
||||
// Created by Martin Lau on 08/08/2018.
|
||||
// Copyright © 2018 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ATRewardedVideoWrapper.h"
|
||||
#import "ATUnityUtilities.h"
|
||||
#import <AnyThinkRewardedVideo/AnyThinkRewardedVideo.h>
|
||||
|
||||
NSString *const kLoadExtraUserIDKey = @"UserId";
|
||||
NSString *const kLoadExtraMediaExtraKey = @"UserExtraData";
|
||||
@interface ATRewardedVideoWrapper()<ATRewardedVideoDelegate>
|
||||
@end
|
||||
@implementation ATRewardedVideoWrapper
|
||||
+(instancetype)sharedInstance {
|
||||
static ATRewardedVideoWrapper *sharedInstance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [[ATRewardedVideoWrapper alloc] init];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
- (id)selWrapperClassWithDict:(NSDictionary *)dict callback:(void(*)(const char*, const char*))callback {
|
||||
NSString *selector = dict[@"selector"];
|
||||
NSArray<NSString*>* arguments = dict[@"arguments"];
|
||||
NSString *firstObject = @"";
|
||||
NSString *lastObject = @"";
|
||||
if (![ATUnityUtilities isEmpty:arguments]) {
|
||||
for (int i = 0; i < arguments.count; i++) {
|
||||
if (i == 0) { firstObject = arguments[i]; }
|
||||
else { lastObject = arguments[i]; }
|
||||
}
|
||||
}
|
||||
|
||||
if ([selector isEqualToString:@"loadRewardedVideoWithPlacementID:customDataJSONString:callback:"]) {
|
||||
[self loadRewardedVideoWithPlacementID:firstObject customDataJSONString:lastObject callback:callback];
|
||||
} else if ([selector isEqualToString:@"rewardedVideoReadyForPlacementID:"]) {
|
||||
return [NSNumber numberWithBool:[self rewardedVideoReadyForPlacementID:firstObject]];
|
||||
} else if ([selector isEqualToString:@"showRewardedVideoWithPlacementID:extraJsonString:"]) {
|
||||
[self showRewardedVideoWithPlacementID:firstObject extraJsonString:lastObject];
|
||||
} else if ([selector isEqualToString:@"checkAdStatus:"]) {
|
||||
return [self checkAdStatus:firstObject];
|
||||
} else if ([selector isEqualToString:@"clearCache"]) {
|
||||
[self clearCache];
|
||||
} else if ([selector isEqualToString:@"setExtra:"]) {
|
||||
[self setExtra:firstObject];
|
||||
} else if ([selector isEqualToString:@"getValidAdCaches:"]) {
|
||||
return [self getValidAdCaches:firstObject];
|
||||
}else if ([selector isEqualToString:@"entryScenarioWithPlacementID:scenarioID:"]) {
|
||||
[self entryScenarioWithPlacementID:firstObject scenarioID:lastObject];
|
||||
}
|
||||
// auto
|
||||
else if ([selector isEqualToString:@"addAutoLoadAdPlacementID:callback:"]){
|
||||
[self addAutoLoadAdPlacementID:firstObject callback:callback];
|
||||
}else if ([selector isEqualToString:@"removeAutoLoadAdPlacementID:"]){
|
||||
[self removeAutoLoadAdPlacementID:firstObject];
|
||||
}else if ([selector isEqualToString:@"autoLoadRewardedVideoReadyForPlacementID:"]){
|
||||
return [NSNumber numberWithBool:[self autoLoadRewardedVideoReadyForPlacementID:firstObject]];
|
||||
}else if ([selector isEqualToString:@"getAutoValidAdCaches:"]){
|
||||
return [self getAutoValidAdCaches:firstObject];
|
||||
}else if ([selector isEqualToString:@"setAutoLocalExtra:customDataJSONString:"]){
|
||||
[self setAutoLocalExtra:firstObject customDataJSONString:lastObject];
|
||||
}else if ([selector isEqualToString:@"entryAutoAdScenarioWithPlacementID:scenarioID:"]){
|
||||
[self entryAutoAdScenarioWithPlacementID:firstObject scenarioID:lastObject];
|
||||
}else if ([selector isEqualToString:@"showAutoRewardedVideoWithPlacementID:extraJsonString:"]){
|
||||
[self showAutoRewardedVideoWithPlacementID:firstObject extraJsonString:lastObject];
|
||||
}else if ([selector isEqualToString:@"checkAutoAdStatus:"]) {
|
||||
return [self checkAutoAdStatus:firstObject];
|
||||
}
|
||||
|
||||
|
||||
return nil;
|
||||
}
|
||||
#pragma mark - normal
|
||||
-(void) loadRewardedVideoWithPlacementID:(NSString*)placementID customDataJSONString:(NSString*)customDataJSONString callback:(void(*)(const char*, const char*))callback {
|
||||
[self setCallBack:callback forKey:placementID];
|
||||
NSMutableDictionary *extra = [NSMutableDictionary dictionary];
|
||||
if ([customDataJSONString isKindOfClass:[NSString class]] && [customDataJSONString length] > 0) {
|
||||
NSDictionary *extraDict = [NSJSONSerialization JSONObjectWithData:[customDataJSONString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
NSLog(@"extraDict = %@", extra);
|
||||
|
||||
if (extraDict[kLoadExtraUserIDKey] != nil) { extra[kATAdLoadingExtraUserIDKey] = extraDict[kLoadExtraUserIDKey]; }
|
||||
if (extraDict[kLoadExtraMediaExtraKey] != nil) { extra[kATAdLoadingExtraMediaExtraKey] = extraDict[kLoadExtraMediaExtraKey]; }
|
||||
}
|
||||
|
||||
[[ATAdManager sharedManager] loadADWithPlacementID:placementID extra:[extra isKindOfClass:[NSMutableDictionary class]] ? extra : nil delegate:self];
|
||||
}
|
||||
|
||||
-(BOOL) rewardedVideoReadyForPlacementID:(NSString*)placementID {
|
||||
return [[ATAdManager sharedManager] rewardedVideoReadyForPlacementID:placementID];
|
||||
}
|
||||
|
||||
-(NSString*) checkAdStatus:(NSString *)placementID {
|
||||
ATCheckLoadModel *checkLoadModel = [[ATAdManager sharedManager] checkRewardedVideoLoadStatusForPlacementID:placementID];
|
||||
NSMutableDictionary *statusDict = [NSMutableDictionary dictionary];
|
||||
statusDict[@"isLoading"] = @(checkLoadModel.isLoading);
|
||||
statusDict[@"isReady"] = @(checkLoadModel.isReady);
|
||||
statusDict[@"adInfo"] = checkLoadModel.adOfferInfo;
|
||||
NSLog(@"ATRewardedVideoWrapper::statusDict = %@", statusDict);
|
||||
return statusDict.jsonFilterString;
|
||||
}
|
||||
|
||||
-(NSString*) getValidAdCaches:(NSString *)placementID {
|
||||
NSArray *array = [[ATAdManager sharedManager] getRewardedVideoValidAdsForPlacementID:placementID];
|
||||
NSLog(@"ATNativeAdWrapper::array = %@", array);
|
||||
return array.jsonFilterString;
|
||||
}
|
||||
|
||||
-(void) showRewardedVideoWithPlacementID:(NSString*)placementID extraJsonString:(NSString*)extraJsonString {
|
||||
NSDictionary *extraDict = ([extraJsonString isKindOfClass:[NSString class]] && [extraJsonString dataUsingEncoding:NSUTF8StringEncoding] != nil) ? [NSJSONSerialization JSONObjectWithData:[extraJsonString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil] : nil;
|
||||
NSLog(@"ATRewardedVideoWrapper::showRewardedVideoWithPlacementID = %@ extraJsonString = %@", placementID,extraJsonString);
|
||||
NSLog(@"ATRewardedVideoWrapper::extraDict = %@", extraDict);
|
||||
[[ATAdManager sharedManager] showRewardedVideoWithPlacementID:placementID scene:extraDict[kATUnityUtilitiesAdShowingExtraScenarioKey] inViewController:[UIApplication sharedApplication].delegate.window.rootViewController delegate:self];
|
||||
}
|
||||
|
||||
-(void) clearCache {
|
||||
|
||||
}
|
||||
|
||||
-(void) setExtra:(NSString*)extra {
|
||||
if ([extra isKindOfClass:[NSString class]]) {
|
||||
NSDictionary *extraDict = [NSJSONSerialization JSONObjectWithData:[extra dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
if ([extraDict isKindOfClass:[NSDictionary class]]) [[ATAdManager sharedManager] setExtra:extraDict];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)entryScenarioWithPlacementID:(NSString *)placementID scenarioID:(NSString *)scenarioID{
|
||||
|
||||
[[ATAdManager sharedManager] entryRewardedVideoScenarioWithPlacementID:placementID scene:scenarioID];
|
||||
}
|
||||
|
||||
-(NSString*) scriptWrapperClass {
|
||||
return @"ATRewardedVideoWrapper";
|
||||
}
|
||||
|
||||
#pragma mark - auto
|
||||
-(void) addAutoLoadAdPlacementID:(NSString*)placementID callback:(void(*)(const char*, const char*))callback {
|
||||
|
||||
if (placementID == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
[ATRewardedVideoAutoAdManager sharedInstance].delegate = self;
|
||||
|
||||
|
||||
NSArray *placementIDArray = [self jsonStrToArray:placementID];
|
||||
|
||||
[placementIDArray enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
[self setCallBack:callback forKey:obj];
|
||||
NSLog(@" addAutoLoadAdPlacementID--%@",placementID);
|
||||
}];
|
||||
[[ATRewardedVideoAutoAdManager sharedInstance] addAutoLoadAdPlacementIDArray:placementIDArray];
|
||||
|
||||
}
|
||||
|
||||
-(void) removeAutoLoadAdPlacementID:(NSString*)placementID{
|
||||
NSLog(@" removeAutoLoadAdPlacementID--%@",placementID);
|
||||
|
||||
if (placementID == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSArray *placementIDArray = [self jsonStrToArray:placementID];
|
||||
|
||||
[[ATRewardedVideoAutoAdManager sharedInstance] removeAutoLoadAdPlacementIDArray:placementIDArray];
|
||||
}
|
||||
|
||||
-(BOOL) autoLoadRewardedVideoReadyForPlacementID:(NSString*)placementID {
|
||||
NSLog(@"Unity: autoLoadRewardedVideoReadyForPlacementID--%@--%d",placementID,[[ATRewardedVideoAutoAdManager sharedInstance] autoLoadRewardedVideoReadyForPlacementID:placementID]);
|
||||
return [[ATRewardedVideoAutoAdManager sharedInstance] autoLoadRewardedVideoReadyForPlacementID:placementID];
|
||||
}
|
||||
|
||||
-(NSString*) getAutoValidAdCaches:(NSString *)placementID{
|
||||
NSArray *array = [[ATRewardedVideoAutoAdManager sharedInstance] checkValidAdCachesWithPlacementID:placementID];
|
||||
NSLog(@"Unity: getAutoValidAdCaches::array = %@", array);
|
||||
return array.jsonFilterString;
|
||||
}
|
||||
|
||||
-(NSString*) checkAutoAdStatus:(NSString *)placementID {
|
||||
ATCheckLoadModel *checkLoadModel = [[ATRewardedVideoAutoAdManager sharedInstance] checkRewardedVideoLoadStatusForPlacementID:placementID];
|
||||
NSMutableDictionary *statusDict = [NSMutableDictionary dictionary];
|
||||
statusDict[@"isLoading"] = @(checkLoadModel.isLoading);
|
||||
statusDict[@"isReady"] = @(checkLoadModel.isReady);
|
||||
statusDict[@"adInfo"] = checkLoadModel.adOfferInfo;
|
||||
NSLog(@"ATRewardedVideoWrapper::checkAutoAdStatus statusDict = %@", statusDict);
|
||||
return statusDict.jsonFilterString;
|
||||
|
||||
}
|
||||
|
||||
-(void) setAutoLocalExtra:(NSString*)placementID customDataJSONString:(NSString*)customDataJSONString{
|
||||
NSLog(@"Unity: setAutoLocalExtra::placementID = %@ customDataJSONString: %@", placementID,customDataJSONString);
|
||||
|
||||
|
||||
|
||||
if ([customDataJSONString isKindOfClass:[NSString class]]) {
|
||||
|
||||
NSDictionary *extraDict = [NSJSONSerialization JSONObjectWithData:[customDataJSONString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
|
||||
NSMutableDictionary *extra = [NSMutableDictionary dictionary];
|
||||
|
||||
|
||||
if ([extraDict isKindOfClass:[NSDictionary class]]) {
|
||||
|
||||
if (extraDict[kLoadExtraUserIDKey] != nil) {
|
||||
extra[kATAdLoadingExtraUserIDKey] = extraDict[kLoadExtraUserIDKey];
|
||||
}
|
||||
if (extraDict[kLoadExtraMediaExtraKey] != nil) { extra[kATAdLoadingExtraMediaExtraKey] = extraDict[kLoadExtraMediaExtraKey];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
[[ATRewardedVideoAutoAdManager sharedInstance] setLocalExtra:extra placementID:placementID];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) entryAutoAdScenarioWithPlacementID:(NSString*)placementID scenarioID:(NSString*)scenarioID{
|
||||
NSLog(@"Unity: getAutoValidAdCaches::array = %@ scenarioID:%@", placementID,scenarioID);
|
||||
|
||||
[[ATRewardedVideoAutoAdManager sharedInstance] entryAdScenarioWithPlacementID:placementID scenarioID:scenarioID];
|
||||
}
|
||||
|
||||
-(void) showAutoRewardedVideoWithPlacementID:(NSString*)placementID extraJsonString:(NSString*)extraJsonString {
|
||||
|
||||
NSDictionary *extraDict = ([extraJsonString isKindOfClass:[NSString class]] && [extraJsonString dataUsingEncoding:NSUTF8StringEncoding] != nil) ? [NSJSONSerialization JSONObjectWithData:[extraJsonString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil] : nil;
|
||||
|
||||
NSLog(@"ATRewardedVideoWrapper::showAutoRewardedVideoWithPlacementID = %@ extraJsonString = %@", placementID,extraJsonString);
|
||||
|
||||
NSLog(@"ATRewardedVideoWrapper::extraDict = %@", extraDict);
|
||||
|
||||
[[ATRewardedVideoAutoAdManager sharedInstance] showAutoLoadRewardedVideoWithPlacementID:placementID scene:extraDict[kATUnityUtilitiesAdShowingExtraScenarioKey] inViewController:[UIApplication sharedApplication].delegate.window.rootViewController delegate:self];
|
||||
}
|
||||
|
||||
#pragma mark - delegate
|
||||
// ad
|
||||
- (void)didStartLoadingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"startLoadingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFinishLoadingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"finishLoadingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFailToLoadADSourceWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra error:(NSError*)error{
|
||||
[self invokeCallback:@"failToLoadADSource" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
// bidding
|
||||
- (void)didStartBiddingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"startBiddingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFinishBiddingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra{
|
||||
[self invokeCallback:@"finishBiddingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
- (void)didFailBiddingADSourceWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra error:(NSError*)error{
|
||||
[self invokeCallback:@"failBiddingADSource" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
|
||||
-(void) didFinishLoadingADWithPlacementID:(NSString *)placementID {
|
||||
[self invokeCallback:@"OnRewardedVideoLoaded" placementID:placementID error:nil extra:nil];
|
||||
}
|
||||
|
||||
-(void) didFailToLoadADWithPlacementID:(NSString*)placementID error:(NSError*)error {
|
||||
error = error != nil ? error : [NSError errorWithDomain:@"com.thinkup.Unity3DPackage" code:100001 userInfo:@{NSLocalizedDescriptionKey:@"AT has failed to load ad", NSLocalizedFailureReasonErrorKey:@"AT has failed to load ad"}];
|
||||
[self invokeCallback:@"OnRewardedVideoLoadFailure" placementID:placementID error:error extra:nil];
|
||||
}
|
||||
|
||||
-(void) rewardedVideoDidStartPlayingForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnRewardedVideoPlayStart" placementID:placementID error:nil extra:extra];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kATUnityUtilitiesRewardedVideoImpressionNotification object:nil];
|
||||
}
|
||||
|
||||
-(void) rewardedVideoDidEndPlayingForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnRewardedVideoPlayEnd" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) rewardedVideoDidFailToPlayForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary *)extra {
|
||||
error = error != nil ? error : [NSError errorWithDomain:@"com.thinkup.Unity3DPackage" code:100001 userInfo:@{NSLocalizedDescriptionKey:@"AT has failed to play video", NSLocalizedFailureReasonErrorKey:@"AT has failed to play video"}];
|
||||
[self invokeCallback:@"OnRewardedVideoPlayFailure" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
-(void) rewardedVideoDidCloseForPlacementID:(NSString*)placementID rewarded:(BOOL)rewarded extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnRewardedVideoClose" placementID:placementID error:nil extra:@{@"rewarded":@(rewarded), @"extra":extra != nil ? extra : @{}}];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kATUnityUtilitiesRewardedVideoCloseNotification object:nil];
|
||||
}
|
||||
|
||||
-(void) rewardedVideoDidClickForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnRewardedVideoClick" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) rewardedVideoDidRewardSuccessForPlacemenID:(NSString*)placementID extra:(NSDictionary*)extra {
|
||||
[self invokeCallback:@"OnRewardedVideoReward" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
//again
|
||||
// rewarded video again
|
||||
-(void) rewardedVideoAgainDidStartPlayingForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {
|
||||
[self invokeCallback:@"OnRewardedVideoAdAgainPlayStart" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) rewardedVideoAgainDidEndPlayingForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {
|
||||
[self invokeCallback:@"OnRewardedVideoAdAgainPlayEnd" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) rewardedVideoAgainDidFailToPlayForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary*)extra {
|
||||
error = error != nil ? error : [NSError errorWithDomain:@"com.thinkup.Unity3DPackage" code:100001 userInfo:@{NSLocalizedDescriptionKey:@"AT has failed to play video", NSLocalizedFailureReasonErrorKey:@"AT has failed to play video"}];
|
||||
[self invokeCallback:@"OnRewardedVideoAdAgainPlayFailed" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
-(void) rewardedVideoAgainDidClickForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {
|
||||
[self invokeCallback:@"OnRewardedVideoAdAgainPlayClicked" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
-(void) rewardedVideoAgainDidRewardSuccessForPlacemenID:(NSString*)placementID extra:(NSDictionary*)extra {
|
||||
[self invokeCallback:@"OnAgainReward" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
@end
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7037fe0b78a946dbb1fe926b3ee4606
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// ATSplashAdWrapper.h
|
||||
// UnityFramework
|
||||
//
|
||||
// Created by li zhixuan on 2023/5/4.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "ATBaseUnityWrapper.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface ATSplashAdWrapper : ATBaseUnityWrapper
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab41f03118f7f43a18d3f953084106c1
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,239 @@
|
||||
//
|
||||
// ATSplashAdWrapper.m
|
||||
// UnityFramework
|
||||
//
|
||||
// Created by li zhixuan on 2023/5/4.
|
||||
//
|
||||
|
||||
#import "ATSplashAdWrapper.h"
|
||||
#import "ATUnityUtilities.h"
|
||||
#import <AnyThinkSplash/AnyThinkSplash.h>
|
||||
|
||||
@interface ATSplashAdWrapper () <ATSplashDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation ATSplashAdWrapper
|
||||
|
||||
+ (instancetype)sharedInstance {
|
||||
static ATSplashAdWrapper *sharedInstance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [[ATSplashAdWrapper alloc] init];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
- (NSString *)scriptWrapperClass {
|
||||
return @"ATSplashAdWrapper";
|
||||
}
|
||||
|
||||
- (id)selWrapperClassWithDict:(NSDictionary *)dict callback:(void(*)(const char*, const char*))callback {
|
||||
NSString *selector = dict[@"selector"];
|
||||
NSArray<NSString*>* arguments = dict[@"arguments"];
|
||||
NSString *firstObject = @"";
|
||||
NSString *lastObject = @"";
|
||||
if (![ATUnityUtilities isEmpty:arguments]) {
|
||||
for (int i = 0; i < arguments.count; i++) {
|
||||
if (i == 0) { firstObject = arguments[i]; }
|
||||
else { lastObject = arguments[i]; }
|
||||
}
|
||||
}
|
||||
|
||||
if ([selector isEqualToString:@"loadSplashAdWithPlacementID:customDataJSONString:callback:"]) {
|
||||
[self loadSplashAdWithPlacementID:firstObject customDataJSONString:lastObject callback:callback];
|
||||
} else if ([selector isEqualToString:@"splashAdReadyForPlacementID:"]) {
|
||||
return [NSNumber numberWithBool:[self splashAdReadyForPlacementID:firstObject]];
|
||||
} else if ([selector isEqualToString:@"showSplashAdWithPlacementID:extraJsonString:"]) {
|
||||
[self showSplashAdWithPlacementID:firstObject extraJsonString:lastObject];
|
||||
} else if ([selector isEqualToString:@"checkAdStatus:"]) {
|
||||
return [self checkAdStatus:firstObject];
|
||||
} else if ([selector isEqualToString:@"clearCache"]) {
|
||||
[self clearCache];
|
||||
} else if ([selector isEqualToString:@"getValidAdCaches:"]) {
|
||||
return [self getValidAdCaches:firstObject];
|
||||
}else if ([selector isEqualToString:@"entryScenarioWithPlacementID:scenarioID:"]) {
|
||||
[self entryScenarioWithPlacementID:firstObject scenarioID:lastObject];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)loadSplashAdWithPlacementID:(NSString*)placementID customDataJSONString:(NSString*)customDataJSONString callback:(void(*)(const char*, const char*))callback {
|
||||
|
||||
[self setCallBack:callback forKey:placementID];
|
||||
NSMutableDictionary *extra = [NSMutableDictionary dictionary];
|
||||
if ([customDataJSONString isKindOfClass:[NSString class]] && [customDataJSONString length] > 0) {
|
||||
NSDictionary *extraDict = [NSJSONSerialization JSONObjectWithData:[customDataJSONString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
[extra addEntriesFromDictionary:extraDict];
|
||||
}
|
||||
NSString *defaultAdSourceConfig = extra[@"default_adSource_config"];
|
||||
NSLog(@"ATSplashAdWrapper::extra = %@", extra);
|
||||
[[ATAdManager sharedManager] loadADWithPlacementID:placementID extra:extra delegate:self containerView:nil];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)splashAdReadyForPlacementID:(NSString*)placementID {
|
||||
return [[ATAdManager sharedManager] splashReadyForPlacementID:placementID];
|
||||
}
|
||||
|
||||
- (NSString*)getValidAdCaches:(NSString *)placementID {
|
||||
NSArray *array = [[ATAdManager sharedManager] getSplashValidAdsForPlacementID:placementID];
|
||||
NSLog(@"ATSplashAdWrapper::array = %@", array);
|
||||
return array.jsonFilterString;
|
||||
}
|
||||
|
||||
- (void)showSplashAdWithPlacementID:(NSString*)placementID extraJsonString:(NSString*)extraJsonString {
|
||||
[[ATAdManager sharedManager] showSplashWithPlacementID:placementID scene:@"" window:[UIApplication sharedApplication].delegate.window delegate:self];
|
||||
}
|
||||
|
||||
- (NSString*)checkAdStatus:(NSString *)placementID {
|
||||
ATCheckLoadModel *checkLoadModel = [[ATAdManager sharedManager] checkSplashLoadStatusForPlacementID:placementID];
|
||||
NSMutableDictionary *statusDict = [NSMutableDictionary dictionary];
|
||||
statusDict[@"isLoading"] = @(checkLoadModel.isLoading);
|
||||
statusDict[@"isReady"] = @(checkLoadModel.isReady);
|
||||
statusDict[@"adInfo"] = checkLoadModel.adOfferInfo;
|
||||
NSLog(@"ATSplashAdWrapper::statusDict = %@", statusDict);
|
||||
return statusDict.jsonFilterString;
|
||||
}
|
||||
|
||||
- (void)entryScenarioWithPlacementID:(NSString *)placementID scenarioID:(NSString *)scenarioID{
|
||||
[[ATAdManager sharedManager] entrySplashScenarioWithPlacementID:placementID scene:scenarioID];
|
||||
}
|
||||
|
||||
- (void) clearCache {
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - ATSplashDelegate
|
||||
/// Splash ad displayed successfully
|
||||
- (void)splashDidShowForPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnSplashAdShow" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
/// Splash ad click
|
||||
- (void)splashDidClickForPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnSplashAdClick" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
/// Splash ad closed
|
||||
- (void)splashDidCloseForPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnSplashAdClose" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
/// Callback when the splash ad is loaded successfully
|
||||
/// @param isTimeout whether timeout
|
||||
/// v 5.7.73
|
||||
- (void)didFinishLoadingSplashADWithPlacementID:(NSString *)placementID
|
||||
isTimeout:(BOOL)isTimeout {
|
||||
}
|
||||
|
||||
/// Splash ad loading timeout callback
|
||||
/// v 5.7.73
|
||||
- (void)didTimeoutLoadingSplashADWithPlacementID:(NSString *)placementID {
|
||||
[self invokeCallback:@"OnSplashAdLoadTimeout" placementID:placementID error:nil extra:nil];
|
||||
}
|
||||
|
||||
/// Splash ad failed to display
|
||||
/// currently supports Pangle, Guangdiantong and Baidu
|
||||
- (void)splashDidShowFailedForPlacementID:(NSString *)placementID
|
||||
error:(NSError *)error
|
||||
extra:(NSDictionary *)extra {
|
||||
[self invokeCallback:@"OnSplashAdFailedToShow" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
/// Whether the click jump of Splash ad is in the form of Deeplink
|
||||
/// note: only suport TopOn Adx ad
|
||||
- (void)splashDeepLinkOrJumpForPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary *)extra
|
||||
result:(BOOL)success {
|
||||
NSMutableDictionary *newExtra = [[NSMutableDictionary alloc] initWithDictionary:extra];
|
||||
newExtra[@"success"] = @(success);
|
||||
[self invokeCallback:@"OnSplashAdDeeplink" placementID:placementID error:nil extra:newExtra];
|
||||
}
|
||||
|
||||
/// Splash ad closes details page
|
||||
- (void)splashDetailDidClosedForPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary *)extra {
|
||||
|
||||
}
|
||||
|
||||
/// Called when splash zoomout view did click
|
||||
/// note: only suport Pangle splash zoomout view and the Tencent splash V+ ad
|
||||
- (void)splashZoomOutViewDidClickForPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary *)extra {
|
||||
|
||||
}
|
||||
|
||||
/// Called when splash zoomout view did close
|
||||
/// note: only suport Pangle splash zoomout view and the Tencent splash V+ ad
|
||||
- (void)splashZoomOutViewDidCloseForPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary *)extra {
|
||||
|
||||
}
|
||||
|
||||
/// This callback is triggered when the skip button is customized.
|
||||
/// note: only suport TopOn MyOffer, TopOn Adx and TopOn OnlineApi
|
||||
/// 5.7.61+
|
||||
- (void)splashCountdownTime:(NSInteger)countdown
|
||||
forPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary *)extra {
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - ATAdLoadingDelegate
|
||||
/// Callback when the successful loading of the ad
|
||||
- (void)didFinishLoadingADWithPlacementID:(NSString *)placementID {
|
||||
[self invokeCallback:@"OnSplashAdLoaded" placementID:placementID error:nil extra:nil];
|
||||
}
|
||||
|
||||
/// Callback of ad loading failure
|
||||
- (void)didFailToLoadADWithPlacementID:(NSString*)placementID
|
||||
error:(NSError*)error {
|
||||
error = error != nil ? error : [NSError errorWithDomain:@"com.thinkup.Unity3DPackage" code:100001 userInfo:@{NSLocalizedDescriptionKey:@"AT has failed to load ad", NSLocalizedFailureReasonErrorKey:@"AT has failed to load ad"}];
|
||||
[self invokeCallback:@"OnSplashAdLoadFailure" placementID:placementID error:error extra:nil];
|
||||
|
||||
}
|
||||
|
||||
/// Ad start load
|
||||
- (void)didStartLoadingADSourceWithPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary*)extra {
|
||||
[self invokeCallback:@"startLoadingADSource" placementID:placementID error:nil extra:extra];
|
||||
|
||||
}
|
||||
/// Ad load success
|
||||
- (void)didFinishLoadingADSourceWithPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary*)extra {
|
||||
[self invokeCallback:@"finishLoadingADSource" placementID:placementID error:nil extra:extra];
|
||||
|
||||
}
|
||||
/// Ad load fail
|
||||
- (void)didFailToLoadADSourceWithPlacementID:(NSString*)placementID
|
||||
extra:(NSDictionary*)extra
|
||||
error:(NSError*)error {
|
||||
[self invokeCallback:@"failToLoadADSource" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
/// Ad start bidding
|
||||
- (void)didStartBiddingADSourceWithPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary*)extra {
|
||||
[self invokeCallback:@"startBiddingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
/// Ad bidding success
|
||||
- (void)didFinishBiddingADSourceWithPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary*)extra {
|
||||
[self invokeCallback:@"finishBiddingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
/// Ad bidding fail
|
||||
- (void)didFailBiddingADSourceWithPlacementID:(NSString*)placementID
|
||||
extra:(NSDictionary*)extra
|
||||
error:(NSError*)error {
|
||||
[self invokeCallback:@"failBiddingADSource" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c2b051645bda46ef877aa87aad0e7af
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// ATUnityManager.h
|
||||
// UnityContainer
|
||||
//
|
||||
// Created by Martin Lau on 08/08/2018.
|
||||
// Copyright © 2018 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ATUnityWrapper.h"
|
||||
|
||||
@interface ATUnityManager : NSObject<ATUnityWrapper>
|
||||
+(instancetype)sharedInstance;
|
||||
- (id)selWrapperClassWithDict:(NSDictionary *)dict callback:(void(*)(const char*))callback;
|
||||
@end
|
||||
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70b6cbc4a5cc245318f37e4f9461803e
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,352 @@
|
||||
//
|
||||
// ATUnityManager.m
|
||||
// UnityContainer
|
||||
//
|
||||
// Created by Martin Lau on 08/08/2018.
|
||||
// Copyright © 2018 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ATUnityManager.h"
|
||||
#import <AnyThinkSDK/AnyThinkSDK.h>
|
||||
#import "ATUnityUtilities.h"
|
||||
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
|
||||
#import <CoreTelephony/CTCarrier.h>
|
||||
#import "ATBannerAdWrapper.h"
|
||||
#import "ATNativeAdWrapper.h"
|
||||
#import "ATInterstitialAdWrapper.h"
|
||||
#import "ATRewardedVideoWrapper.h"
|
||||
|
||||
/*
|
||||
*class:
|
||||
*selector:
|
||||
*arguments:
|
||||
*/
|
||||
bool at_message_from_unity(const char *msg, void(*callback)(const char*, const char *)) {
|
||||
NSString *msgStr = [NSString stringWithUTF8String:msg];
|
||||
NSDictionary *msgDict = [NSJSONSerialization JSONObjectWithData:[msgStr dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
Class class = NSClassFromString(msgDict[@"class"]);
|
||||
|
||||
bool ret = false;
|
||||
ret = [[[class sharedInstance] selWrapperClassWithDict:msgDict callback:callback != NULL ? callback : nil] boolValue];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int at_get_message_for_unity(const char *msg, void(*callback)(const char*, const char *)) {
|
||||
NSString *msgStr = [NSString stringWithUTF8String:msg];
|
||||
NSDictionary *msgDict = [NSJSONSerialization JSONObjectWithData:[msgStr dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
|
||||
Class class = NSClassFromString(msgDict[@"class"]);
|
||||
|
||||
int ret = 0;
|
||||
ret = [[[class sharedInstance] selWrapperClassWithDict:msgDict callback:callback != NULL ? callback : nil] intValue];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
char * at_get_string_message_for_unity(const char *msg, void(*callback)(const char*, const char *)) {
|
||||
NSString *msgStr = [NSString stringWithUTF8String:msg];
|
||||
NSDictionary *msgDict = [NSJSONSerialization JSONObjectWithData:[msgStr dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
|
||||
Class class = NSClassFromString(msgDict[@"class"]);
|
||||
|
||||
NSString *ret = @"";
|
||||
ret = [[class sharedInstance] selWrapperClassWithDict:msgDict callback:callback != NULL ? callback : nil];
|
||||
|
||||
if ([ret UTF8String] == NULL)
|
||||
return NULL;
|
||||
|
||||
char* res = (char*)malloc(strlen([ret UTF8String]) + 1);
|
||||
strcpy(res, [ret UTF8String]);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@interface ATUnityManager()
|
||||
@property(nonatomic, readonly) NSMutableDictionary *consentInfo;
|
||||
@end
|
||||
@implementation ATUnityManager
|
||||
+(instancetype)sharedInstance {
|
||||
static ATUnityManager *sharedInstance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [[ATUnityManager alloc] init];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
-(instancetype) init {
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_consentInfo = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)selWrapperClassWithDict:(NSDictionary *)dict callback:(void(*)(const char*))callback {
|
||||
NSString *selector = dict[@"selector"];
|
||||
NSArray<NSString*>* arguments = dict[@"arguments"];
|
||||
NSString *firstObject = @"";
|
||||
NSString *lastObject = @"";
|
||||
if (![ATUnityUtilities isEmpty:arguments]) {
|
||||
for (int i = 0; i < arguments.count; i++) {
|
||||
if (i == 0) { firstObject = arguments[i]; }
|
||||
else { lastObject = arguments[i]; }
|
||||
}
|
||||
}
|
||||
|
||||
if ([selector isEqualToString:@"startSDKWithAppID:appKey:"]) {
|
||||
return [NSNumber numberWithBool:[self startSDKWithAppID:firstObject appKey:lastObject]];
|
||||
} else if ([selector isEqualToString:@"subjectToGDPR"]) {
|
||||
return [NSNumber numberWithBool:[self subjectToGDPR]];
|
||||
}else if ([selector isEqualToString:@"showGDPRConsentDialog:"]) {
|
||||
[self showGDPRConsentDialog:callback];
|
||||
} else if ([selector isEqualToString:@"getUserLocation:"]) {
|
||||
[self getUserLocation:callback];
|
||||
} else if ([selector isEqualToString:@"setPurchaseFlag"]) {
|
||||
[self setPurchaseFlag];
|
||||
} else if ([selector isEqualToString:@"clearPurchaseFlag"]) {
|
||||
[self clearPurchaseFlag];
|
||||
} else if ([selector isEqualToString:@"purchaseFlag"]) {
|
||||
return [NSNumber numberWithBool:[self purchaseFlag]];
|
||||
} else if ([selector isEqualToString:@"setChannel:"]) {
|
||||
[self setChannel:firstObject];
|
||||
} else if ([selector isEqualToString:@"setSubChannel:"]) {
|
||||
[self setSubChannel:firstObject];
|
||||
} else if ([selector isEqualToString:@"setCustomData:"]) {
|
||||
[self setCustomData:firstObject];
|
||||
} else if ([selector isEqualToString:@"setCustomData:forPlacementID:"]) {
|
||||
[self setCustomData:firstObject forPlacementID:lastObject];
|
||||
} else if ([selector isEqualToString:@"setDebugLog:"]) {
|
||||
[self setDebugLog:firstObject];
|
||||
} else if ([selector isEqualToString:@"getDataConsent"]) {
|
||||
return [NSNumber numberWithInt:[self getDataConsent]];
|
||||
} else if ([selector isEqualToString:@"setDataConsent:"]) {
|
||||
[self setDataConsent:[NSNumber numberWithInt:firstObject.intValue]];
|
||||
} else if ([selector isEqualToString:@"inDataProtectionArea"]) {
|
||||
return [NSNumber numberWithBool:[self inDataProtectionArea]];
|
||||
} else if ([selector isEqualToString:@"deniedUploadDeviceInfo:"]) {
|
||||
[self deniedUploadDeviceInfo:firstObject];
|
||||
} else if ([selector isEqualToString:@"setDataConsent:network:"]) {
|
||||
[self setDataConsent:firstObject network:[NSNumber numberWithInt:lastObject.intValue]];
|
||||
} else if ([selector isEqualToString:@"setExcludeBundleIdArray:"]) {
|
||||
[self setExcludeBundleIdArray:firstObject];
|
||||
} else if ([selector isEqualToString:@"setExludePlacementid:unitIDArray:"]) {
|
||||
[self setExludePlacementid:firstObject unitIDArray:lastObject];
|
||||
} else if ([selector isEqualToString:@"setSDKArea:"]) {
|
||||
[self setSDKArea:[NSNumber numberWithInt:firstObject.intValue]];
|
||||
} else if ([selector isEqualToString:@"getArea:"]) {
|
||||
[self getArea:callback];
|
||||
} else if ([selector isEqualToString:@"setWXStatus:"]) {
|
||||
[self setWXStatus:[NSNumber numberWithDouble:firstObject.boolValue]];
|
||||
} else if ([selector isEqualToString:@"setLocationLongitude:dimension:"]) {
|
||||
[self setLocationLongitude:[NSNumber numberWithDouble:firstObject.doubleValue] dimension:[NSNumber numberWithDouble:lastObject.doubleValue]];
|
||||
}else if ([selector isEqualToString:@"showDebuggerUI:"]) {
|
||||
[self showDebuggerUI:firstObject];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(BOOL) startSDKWithAppID:(NSString*)appID appKey:(NSString*)appKey {
|
||||
[[ATSDKGlobalSetting sharedManager] setSystemPlatformType:ATSystemPlatformTypeUnity];
|
||||
return [[ATAPI sharedInstance] startWithAppID:appID appKey:appKey error:nil];
|
||||
}
|
||||
|
||||
- (BOOL) subjectToGDPR {
|
||||
return [@[@"AT", @"BE", @"BG", @"HR", @"CY", @"CZ", @"DK", @"EE", @"FI", @"FR", @"DE", @"GR", @"HU", @"IS", @"IE", @"IT", @"LV", @"LI", @"LT", @"LU", @"MT", @"NL", @"NO", @"PL", @"PT", @"RO", @"SK", @"SI", @"ES", @"SE", @"GB", @"UK"] containsObject:[[CTTelephonyNetworkInfo new].subscriberCellularProvider.isoCountryCode length] > 0 ? [[CTTelephonyNetworkInfo new].subscriberCellularProvider.isoCountryCode uppercaseString] : @""];
|
||||
}
|
||||
|
||||
-(void) showGDPRConsentDialog:(void(*)(const char*))callback {
|
||||
[[ATAPI sharedInstance] showGDPRConsentDialogInViewController:[UIApplication sharedApplication].delegate.window.rootViewController dismissalCallback:^{
|
||||
if (callback != NULL) { callback(@"".UTF8String); }
|
||||
}];
|
||||
}
|
||||
|
||||
-(void) getUserLocation:(void(*)(const char*))callback {
|
||||
[[ATAPI sharedInstance] getUserLocationWithCallback:^(ATUserLocation location) {
|
||||
if (callback != NULL) { callback(@(location).stringValue.UTF8String); }
|
||||
}];
|
||||
}
|
||||
|
||||
-(void) setPurchaseFlag {
|
||||
|
||||
}
|
||||
|
||||
-(void) clearPurchaseFlag {
|
||||
|
||||
}
|
||||
|
||||
-(BOOL) purchaseFlag {
|
||||
return NO;
|
||||
}
|
||||
|
||||
-(void) setChannel:(NSString*)channel {
|
||||
[[ATSDKGlobalSetting sharedManager] setChannel:channel];
|
||||
}
|
||||
|
||||
-(void) setSubChannel:(NSString*)subChannel {
|
||||
[[ATSDKGlobalSetting sharedManager] setSubchannel:subChannel];
|
||||
}
|
||||
|
||||
-(void) setCustomData:(NSString*)customDataStr {
|
||||
if ([customDataStr isKindOfClass:[NSString class]] && [customDataStr length] > 0) {
|
||||
NSDictionary *customData = [NSJSONSerialization JSONObjectWithData:[customDataStr dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
[[ATSDKGlobalSetting sharedManager] setCustomData:customData];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) setCustomData:(NSString*)customDataStr forPlacementID:(NSString*)placementID {
|
||||
if ([customDataStr isKindOfClass:[NSString class]] && [customDataStr length] > 0) {
|
||||
NSDictionary *customData = [NSJSONSerialization JSONObjectWithData:[customDataStr dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
[[ATSDKGlobalSetting sharedManager] setCustomData:customData forPlacementID:placementID];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) setDebugLog:(NSString*)flagStr {
|
||||
[ATAPI setLogEnabled:[flagStr boolValue]];
|
||||
}
|
||||
|
||||
-(int) getDataConsent {
|
||||
return [@{@(ATDataConsentSetPersonalized):@0, @(ATDataConsentSetNonpersonalized):@1, @(ATDataConsentSetUnknown):@2}[@([ATAPI sharedInstance].dataConsentSet)] intValue];
|
||||
}
|
||||
|
||||
-(void) setDataConsent:(NSNumber*)dataConsent {
|
||||
[[ATAPI sharedInstance] setDataConsentSet:[@{@0:@(ATDataConsentSetPersonalized), @1:@(ATDataConsentSetNonpersonalized), @2:@(ATDataConsentSetUnknown)}[dataConsent] integerValue] consentString:@{}];
|
||||
}
|
||||
|
||||
-(BOOL) inDataProtectionArea {
|
||||
return [[ATAPI sharedInstance] inDataProtectionArea];
|
||||
}
|
||||
|
||||
-(void) deniedUploadDeviceInfo:(NSString *)deniedInfo {
|
||||
NSLog(@"ATUnityManager::deniedUploadDeviceInfo = %@", deniedInfo);
|
||||
if (![ATUnityUtilities isEmpty:deniedInfo]) {
|
||||
NSArray *deniedInfoArray = [NSJSONSerialization JSONObjectWithData:[deniedInfo dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
[[ATSDKGlobalSetting sharedManager] setDeniedUploadInfoArray:deniedInfoArray];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
-(void) setDataConsent:(NSString*)consentJsonString network:(NSNumber*)network {
|
||||
NSLog(@"API was deprecated, please use SetDataConsent(int consent)");
|
||||
// NSLog(@"constenJsonString = %@, network = %@", consentJsonString, network);
|
||||
// NSDictionary *networks = @{@1:kATNetworkNameFacebook, @2:kATNetworkNameAdmob, @3:kATNetworkNameInmobi, @4:kATNetworkNameFlurry, @5:kATNetworkNameApplovin, @6:kATNetworkNameMintegral, @8:kATNetworkNameGDT, @9:kATNetworkNameChartboost, @10:kATNetworkNameTapjoy, @11:kATNetworkNameIronSource, @12:kATNetworkNameUnityAds, @13:kATNetworkNameVungle, @14:kATNetworkNameAdColony, @1:kATNetworkNameOneway, @18:kATNetworkNameMobPower, @20:kATNetworkNameYeahmobi, @21:kATNetworkNameAppnext, @22:kATNetworkNameBaidu};
|
||||
// if ([networks containsObjectForKey:network]) {
|
||||
// if (([consentJsonString isKindOfClass:[NSString class]] && [consentJsonString dataUsingEncoding:NSUTF8StringEncoding] != nil)) {
|
||||
// NSDictionary *consentDict = [NSJSONSerialization JSONObjectWithData:[consentJsonString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
// _consentInfo[networks[network]] = [consentDict containsObjectForKey:@"value"] ? consentDict[@"value"] : consentDict;
|
||||
// } else {
|
||||
// [_consentInfo removeObjectForKey:networks[network]];
|
||||
// }
|
||||
// NSLog(@"consentInfo = %@", _consentInfo);
|
||||
// if ([_consentInfo[kATNetworkNameMintegral] isKindOfClass:[NSDictionary class]]) {
|
||||
// NSMutableDictionary<NSNumber*, NSNumber*>* mintegralInfo = [NSMutableDictionary<NSNumber*, NSNumber*> dictionary];
|
||||
// [_consentInfo[kATNetworkNameMintegral] enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
|
||||
// if ([key respondsToSelector:@selector(integerValue)] && [obj respondsToSelector:@selector(integerValue)]) mintegralInfo[@([key integerValue])] = @([obj integerValue]);
|
||||
// }];
|
||||
// NSLog(@"consentInfo = %@, %@", [((NSDictionary*)_consentInfo[kATNetworkNameMintegral]).allKeys[0] class], [((NSDictionary*)_consentInfo[kATNetworkNameMintegral]).allValues[0] class]);
|
||||
// _consentInfo[kATNetworkNameMintegral] = mintegralInfo;
|
||||
// NSLog(@"consentInfo = %@, %@", [((NSDictionary*)_consentInfo[kATNetworkNameMintegral]).allKeys[0] class], [((NSDictionary*)_consentInfo[kATNetworkNameMintegral]).allValues[0] class]);
|
||||
// }
|
||||
// [[ATAPI sharedInstance] setNetworkConsentInfo:_consentInfo];
|
||||
// }
|
||||
}
|
||||
|
||||
-(void) setExcludeBundleIdArray:(NSString*)bundleIds {
|
||||
NSLog(@"ATUnityManager::setExcludeBundleIdArray = %@", bundleIds);
|
||||
if (![ATUnityUtilities isEmpty:bundleIds]) {
|
||||
NSArray *bundleIdArray = [NSJSONSerialization JSONObjectWithData:[bundleIds dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
[[ATSDKGlobalSetting sharedManager] setExludeAppleIdArray:bundleIdArray];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) setExludePlacementid:(NSString*)placementID unitIDArray:(NSString*)adsourceIds {
|
||||
NSLog(@"ATUnityManager::setExludePlacementid=%@ adsourceIds= %@",placementID ,adsourceIds);
|
||||
if (![ATUnityUtilities isEmpty:adsourceIds]) {
|
||||
NSArray *adsourceIdArray = [NSJSONSerialization JSONObjectWithData:[adsourceIds dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
[[ATAdManager sharedManager] setExludePlacementid:placementID
|
||||
unitIDArray:adsourceIdArray];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) setSDKArea:(NSNumber*)area {
|
||||
NSLog(@"ATUnityManager::setSDKArea=%@",area);
|
||||
}
|
||||
|
||||
-(void) getArea:(void(*)(const char *))callback {
|
||||
NSLog(@"ATUnityManager::getArea");
|
||||
NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
|
||||
[[ATAPI sharedInstance] getAreaSuccess:^(NSString *areaCodeStr) {
|
||||
NSLog(@"ATUnityManager::getArea:Success:%@",areaCodeStr);
|
||||
if (areaCodeStr != nil) {
|
||||
resultDict[@"areaCode"] = areaCodeStr;
|
||||
if (callback != NULL) { callback(resultDict.jsonString.UTF8String); }
|
||||
}
|
||||
} failure:^(NSError *error) {
|
||||
NSLog(@"ATUnityManager::getArea:failure:%@",error.domain);
|
||||
if (error.domain != nil) {
|
||||
resultDict[@"errorMsg"] = error.domain;
|
||||
if (callback != NULL) { callback(resultDict.jsonString.UTF8String); }
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
-(void) setWXStatus:(NSNumber *)flag {
|
||||
NSLog(@"ATUnityManager::setWXStatus=%d",flag.boolValue);
|
||||
[ATSDKGlobalSetting sharedManager].isInstallWX = flag.boolValue;
|
||||
}
|
||||
|
||||
-(void) setLocationLongitude:(NSNumber*)longitude dimension:(NSNumber*)latitude {
|
||||
NSLog(@"ATUnityManager::setLocationLongitude=%@ dimension=%@",longitude,latitude);
|
||||
[[ATSDKGlobalSetting sharedManager] setLocationLongitude:longitude.doubleValue dimension:latitude.doubleValue];
|
||||
}
|
||||
|
||||
- (void)showDebuggerUI:(NSString *)debugKey {
|
||||
NSLog(@"ATUnityManager::showDebuggerUI with key: %@", debugKey);
|
||||
NSString *classStr = @"ATDebuggerAPI";
|
||||
Class debuggerAPIClass = NSClassFromString(classStr);
|
||||
if(!debuggerAPIClass) {
|
||||
NSLog(@"ATUnityManager::showDebuggerUI - NO %@", classStr);
|
||||
return;
|
||||
}
|
||||
|
||||
SEL sharedInstanceSel = @selector(sharedInstance);
|
||||
if (![debuggerAPIClass respondsToSelector:sharedInstanceSel]) {
|
||||
NSLog(@"ATUnityManager::showDebuggerUI - NO sharedInstance selector");
|
||||
return;
|
||||
}
|
||||
|
||||
// 通过sharedInstanceSel获取单例对象
|
||||
id debugger = [debuggerAPIClass performSelector:sharedInstanceSel];
|
||||
|
||||
NSString *functionStr = @"showDebuggerInViewController:showType:debugkey:";
|
||||
SEL sel = NSSelectorFromString(functionStr);
|
||||
if ([debugger respondsToSelector:sel]) {
|
||||
NSMethodSignature *signature = [debugger methodSignatureForSelector:sel];
|
||||
if (signature) {
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
|
||||
[invocation setTarget:debugger];
|
||||
[invocation setSelector:sel];
|
||||
|
||||
// 设置参数
|
||||
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
|
||||
UIViewController *rootViewController = keyWindow.rootViewController;
|
||||
NSNumber *showType = @1; // 假设 showType 为1
|
||||
|
||||
[invocation setArgument:&rootViewController atIndex:2]; // 注意:参数索引从2开始,0和1被target和selector占用
|
||||
[invocation setArgument:&showType atIndex:3];
|
||||
[invocation setArgument:&debugKey atIndex:4];
|
||||
|
||||
// 调用方法
|
||||
[invocation invoke];
|
||||
}
|
||||
} else {
|
||||
NSLog(@"ATUnityManager::showDebuggerUI - NO %@", functionStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96a36282dd3a94ea8af07c487cda010a
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// ATSafeThreadDictionary.h
|
||||
// ATSDK
|
||||
//
|
||||
// Created by topon on 2020/9/21.
|
||||
// Copyright © 2020 AnyThink. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
A simple implementation of thread safe mutable dictionary.
|
||||
|
||||
@discussion Generally, access performance is lower than NSMutableDictionary,
|
||||
but higher than using @synchronized, NSLock, or pthread_mutex_t.
|
||||
|
||||
@warning Fast enumerate(for...in) and enumerator is not thread safe,
|
||||
use enumerate using block instead. When enumerate or sort with block/callback,
|
||||
do *NOT* send message to the dictionary inside the block/callback.
|
||||
*/
|
||||
@interface ATUnitySafeThreadDictionary<KeyType, ObjectType> : NSMutableDictionary
|
||||
|
||||
@end
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab0c2685dc7d04380849cf28dd93a782
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
// ATSafeThreadDictionary.h
|
||||
// ATSDK
|
||||
//
|
||||
// Created by topon on 2020/9/21.
|
||||
// Copyright © 2020 AnyThink. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ATUnitySafeThreadDictionary.h"
|
||||
#import <pthread.h>
|
||||
|
||||
|
||||
#define INIT(...) self = super.init; \
|
||||
if (!self) return nil; \
|
||||
__VA_ARGS__; \
|
||||
if (!_dic) return nil; \
|
||||
[self __initMutex:&_mutex_lock];\
|
||||
return self;
|
||||
|
||||
|
||||
#define LOCK(...) pthread_mutex_lock(&_mutex_lock); \
|
||||
__VA_ARGS__; \
|
||||
pthread_mutex_unlock(&_mutex_lock);
|
||||
|
||||
@implementation ATUnitySafeThreadDictionary {
|
||||
NSMutableDictionary *_dic; //Subclass a class cluster...
|
||||
pthread_mutex_t _mutex_lock;
|
||||
pthread_mutexattr_t _attr;
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - init
|
||||
|
||||
- (void)__initMutex:(pthread_mutex_t *)mutex {
|
||||
// 递归锁:允许同一个线程对一把锁进行重复加锁
|
||||
// 初始化属性
|
||||
pthread_mutexattr_init(&_attr);
|
||||
pthread_mutexattr_settype(&_attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
// 初始化锁
|
||||
pthread_mutex_init(mutex, &_attr);
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
|
||||
INIT(_dic = [[NSMutableDictionary alloc] init]);
|
||||
}
|
||||
|
||||
- (instancetype)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys {
|
||||
INIT(_dic = [[NSMutableDictionary alloc] initWithObjects:objects forKeys:keys]);
|
||||
}
|
||||
|
||||
- (instancetype)initWithCapacity:(NSUInteger)capacity {
|
||||
INIT(_dic = [[NSMutableDictionary alloc] initWithCapacity:capacity]);
|
||||
}
|
||||
|
||||
- (instancetype)initWithObjects:(const id[])objects forKeys:(const id <NSCopying>[])keys count:(NSUInteger)cnt {
|
||||
INIT(_dic = [[NSMutableDictionary alloc] initWithObjects:objects forKeys:keys count:cnt]);
|
||||
}
|
||||
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)otherDictionary {
|
||||
INIT(_dic = [[NSMutableDictionary alloc] initWithDictionary:otherDictionary]);
|
||||
}
|
||||
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)otherDictionary copyItems:(BOOL)flag {
|
||||
INIT(_dic = [[NSMutableDictionary alloc] initWithDictionary:otherDictionary copyItems:flag]);
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - method
|
||||
|
||||
- (NSUInteger)count {
|
||||
LOCK(NSUInteger c = _dic.count); return c;
|
||||
}
|
||||
|
||||
- (id)objectForKey:(id)aKey {
|
||||
LOCK(id o = [_dic objectForKey:aKey]); return o;
|
||||
}
|
||||
|
||||
- (NSEnumerator *)keyEnumerator {
|
||||
LOCK(NSEnumerator * e = [_dic keyEnumerator]); return e;
|
||||
}
|
||||
|
||||
- (NSArray *)allKeys {
|
||||
LOCK(NSArray * a = [_dic allKeys]); return a;
|
||||
}
|
||||
|
||||
- (NSArray *)allKeysForObject:(id)anObject {
|
||||
LOCK(NSArray * a = [_dic allKeysForObject:anObject]); return a;
|
||||
}
|
||||
|
||||
- (NSArray *)allValues {
|
||||
LOCK(NSArray * a = [_dic allValues]); return a;
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
LOCK(NSString * d = [_dic description]); return d;
|
||||
}
|
||||
|
||||
- (NSString *)descriptionInStringsFileFormat {
|
||||
LOCK(NSString * d = [_dic descriptionInStringsFileFormat]); return d;
|
||||
}
|
||||
|
||||
- (NSString *)descriptionWithLocale:(id)locale {
|
||||
LOCK(NSString * d = [_dic descriptionWithLocale:locale]); return d;
|
||||
}
|
||||
|
||||
- (NSString *)descriptionWithLocale:(id)locale indent:(NSUInteger)level {
|
||||
LOCK(NSString * d = [_dic descriptionWithLocale:locale indent:level]); return d;
|
||||
}
|
||||
|
||||
- (BOOL)isEqualToDictionary:(NSDictionary *)otherDictionary {
|
||||
if (otherDictionary == self) return YES;
|
||||
|
||||
if ([otherDictionary isKindOfClass:ATUnitySafeThreadDictionary.class]) {
|
||||
ATUnitySafeThreadDictionary *other = (id)otherDictionary;
|
||||
BOOL isEqual;
|
||||
pthread_mutex_lock(&_mutex_lock);
|
||||
pthread_mutex_lock(&(other->_mutex_lock));
|
||||
isEqual = [_dic isEqual:other->_dic];
|
||||
pthread_mutex_unlock(&_mutex_lock);
|
||||
pthread_mutex_unlock(&(other->_mutex_lock));
|
||||
return isEqual;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSEnumerator *)objectEnumerator {
|
||||
LOCK(NSEnumerator * e = [_dic objectEnumerator]); return e;
|
||||
}
|
||||
|
||||
- (NSArray *)objectsForKeys:(NSArray *)keys notFoundMarker:(id)marker {
|
||||
LOCK(NSArray * a = [_dic objectsForKeys:keys notFoundMarker:marker]); return a;
|
||||
}
|
||||
|
||||
- (NSArray *)keysSortedByValueUsingSelector:(SEL)comparator {
|
||||
LOCK(NSArray * a = [_dic keysSortedByValueUsingSelector:comparator]); return a;
|
||||
}
|
||||
|
||||
- (void)getObjects:(id __unsafe_unretained[])objects andKeys:(id __unsafe_unretained[])keys {
|
||||
LOCK([_dic getObjects:objects andKeys:keys]);
|
||||
}
|
||||
|
||||
- (id)objectForKeyedSubscript:(id)key {
|
||||
LOCK(id o = [_dic objectForKeyedSubscript:key]); return o;
|
||||
}
|
||||
|
||||
- (void)enumerateKeysAndObjectsUsingBlock:(__attribute__((noescape)) void (^)(id key, id obj, BOOL *stop))block {
|
||||
LOCK([_dic enumerateKeysAndObjectsUsingBlock:block]);
|
||||
}
|
||||
|
||||
- (void)enumerateKeysAndObjectsWithOptions:(NSEnumerationOptions)opts usingBlock:(__attribute__((noescape)) void (^)(id key, id obj, BOOL *stop))block {
|
||||
LOCK([_dic enumerateKeysAndObjectsWithOptions:opts usingBlock:block]);
|
||||
}
|
||||
|
||||
- (NSArray *)keysSortedByValueUsingComparator:(__attribute__((noescape)) NSComparator)cmptr {
|
||||
LOCK(NSArray * a = [_dic keysSortedByValueUsingComparator:cmptr]); return a;
|
||||
}
|
||||
|
||||
- (NSArray *)keysSortedByValueWithOptions:(NSSortOptions)opts usingComparator:(__attribute__((noescape)) NSComparator)cmptr {
|
||||
LOCK(NSArray * a = [_dic keysSortedByValueWithOptions:opts usingComparator:cmptr]); return a;
|
||||
}
|
||||
|
||||
- (NSSet *)keysOfEntriesPassingTest:(__attribute__((noescape)) BOOL (^)(id key, id obj, BOOL *stop))predicate {
|
||||
LOCK(NSSet * a = [_dic keysOfEntriesPassingTest:predicate]); return a;
|
||||
}
|
||||
|
||||
- (NSSet *)keysOfEntriesWithOptions:(NSEnumerationOptions)opts passingTest:(__attribute__((noescape)) BOOL (^)(id key, id obj, BOOL *stop))predicate {
|
||||
LOCK(NSSet * a = [_dic keysOfEntriesWithOptions:opts passingTest:predicate]); return a;
|
||||
}
|
||||
|
||||
#pragma mark - mutable
|
||||
|
||||
- (void)removeObjectForKey:(id)aKey {
|
||||
LOCK(
|
||||
if (aKey) {
|
||||
[_dic removeObjectForKey:aKey];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)setObject:(id)anObject forKey:(id <NSCopying> )aKey {
|
||||
LOCK(
|
||||
if (anObject && aKey) {
|
||||
[_dic setObject:anObject forKey:aKey];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)addEntriesFromDictionary:(NSDictionary *)otherDictionary {
|
||||
LOCK(
|
||||
if (otherDictionary) {
|
||||
[_dic addEntriesFromDictionary:otherDictionary];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)removeAllObjects {
|
||||
LOCK([_dic removeAllObjects]);
|
||||
}
|
||||
|
||||
- (void)removeObjectsForKeys:(NSArray *)keyArray {
|
||||
LOCK([_dic removeObjectsForKeys:keyArray]);
|
||||
}
|
||||
|
||||
- (void)setDictionary:(NSDictionary *)otherDictionary {
|
||||
LOCK(
|
||||
if (otherDictionary) {
|
||||
[_dic setDictionary:otherDictionary];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying> )key {
|
||||
LOCK(
|
||||
if (obj && key) {
|
||||
[_dic setObject:obj forKeyedSubscript:key];
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - protocol
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone {
|
||||
return [self mutableCopyWithZone:zone];
|
||||
}
|
||||
|
||||
- (id)mutableCopyWithZone:(NSZone *)zone {
|
||||
LOCK(id copiedDictionary = [[self.class allocWithZone:zone] initWithDictionary:_dic]);
|
||||
return copiedDictionary;
|
||||
}
|
||||
|
||||
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
|
||||
objects:(id __unsafe_unretained[])stackbuf
|
||||
count:(NSUInteger)len {
|
||||
LOCK(NSUInteger count = [_dic countByEnumeratingWithState:state objects:stackbuf count:len]);
|
||||
return count;
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(id)object {
|
||||
if (object == self) return YES;
|
||||
|
||||
if ([object isKindOfClass:ATUnitySafeThreadDictionary.class]) {
|
||||
ATUnitySafeThreadDictionary *other = object;
|
||||
BOOL isEqual;
|
||||
pthread_mutex_lock(&_mutex_lock);
|
||||
pthread_mutex_lock(&(other->_mutex_lock));
|
||||
isEqual = [_dic isEqual:other->_dic];
|
||||
pthread_mutex_unlock(&_mutex_lock);
|
||||
pthread_mutex_unlock(&(other->_mutex_lock));
|
||||
|
||||
return isEqual;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSUInteger)hash {
|
||||
LOCK(NSUInteger hash = [_dic hash]);
|
||||
return hash;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
pthread_mutex_destroy(&_mutex_lock);
|
||||
pthread_mutexattr_destroy(&_attr);
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cd58417f01ca4bbaae4e056637c96e9
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// ATUnityUtilities.h
|
||||
// UnityContainer
|
||||
//
|
||||
// Created by Martin Lau on 14/08/2018.
|
||||
// Copyright © 2018 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
extern NSString *const kATUnityUtilitiesInterstitialImpressionNotification;
|
||||
extern NSString *const kATUnityUtilitiesInterstitialCloseNotification;
|
||||
extern NSString *const kATUnityUtilitiesRewardedVideoImpressionNotification;
|
||||
extern NSString *const kATUnityUtilitiesRewardedVideoCloseNotification;
|
||||
extern NSString *const kATUnityUtilitiesAdShowingExtraScenarioKey;
|
||||
extern NSString *const kATUnityUserExtraDataKey;
|
||||
extern NSString *const kATUnityCheckLoadModelAdInfoKey;
|
||||
|
||||
|
||||
@interface ATUnityUtilities : NSObject
|
||||
+(BOOL)isEmpty:(id)object;
|
||||
@end
|
||||
|
||||
@interface NSDictionary (KAKit)
|
||||
-(NSString*) jsonString;
|
||||
|
||||
// 过滤SDK返回参数的 user_load_extra_data 中不支持的类型
|
||||
-(NSString*) jsonFilterString;
|
||||
|
||||
-(BOOL)containsObjectForKey:(id)key;
|
||||
@end
|
||||
|
||||
@interface NSArray (KAKit)
|
||||
-(NSString*) jsonString;
|
||||
|
||||
// 过滤SDK返回参数的 user_load_extra_data 中不支持的类型
|
||||
-(NSString*) jsonFilterString;
|
||||
@end
|
||||
|
||||
@interface NSData(ATKit)
|
||||
+(instancetype) dataWithUTF8String:(const char*)string;
|
||||
@end
|
||||
|
||||
@interface UIColor (Hex)
|
||||
// 透明度固定为1,以0x开头的十六进制转换成的颜色
|
||||
+ (UIColor *)colorWithHex:(long)hexColor;
|
||||
// 0x开头的十六进制转换成的颜色,透明度可调整
|
||||
+ (UIColor *)colorWithHex:(long)hexColor alpha:(float)opacity;
|
||||
// 颜色转换三:iOS中十六进制的颜色(以#开头)转换为UIColor
|
||||
+ (UIColor *) colorWithHexString: (NSString *)color;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0ace8b47781345a7b6974e14b64efbb
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,216 @@
|
||||
//
|
||||
// ATUnityUtilities.m
|
||||
// UnityContainer
|
||||
//
|
||||
// Created by Martin Lau on 14/08/2018.
|
||||
// Copyright © 2018 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ATUnityUtilities.h"
|
||||
NSString *const kATUnityUtilitiesInterstitialImpressionNotification = @"com.thinkup.kATUnityUtilitiesInterstitialImpressionNotification";
|
||||
NSString *const kATUnityUtilitiesInterstitialCloseNotification = @"kATUnityUtilitiesInterstitialCloseNotification";
|
||||
NSString *const kATUnityUtilitiesRewardedVideoImpressionNotification = @"kATUnityUtilitiesRewardedVideoImpressionNotification";
|
||||
NSString *const kATUnityUtilitiesRewardedVideoCloseNotification = @"kATUnityUtilitiesRewardedVideoCloseNotification";
|
||||
NSString *const kATUnityUtilitiesAdShowingExtraScenarioKey = @"Scenario";
|
||||
|
||||
NSString *const kATUnityUserExtraDataKey = @"user_load_extra_data";
|
||||
NSString *const kATUnityCheckLoadModelAdInfoKey = @"adInfo";
|
||||
|
||||
@implementation ATUnityUtilities
|
||||
+(BOOL)isEmpty:(id)object {
|
||||
return (object == nil || [object isKindOfClass:[NSNull class]] || ([object respondsToSelector:@selector(length)] && [(NSData *)object length] == 0) || ([object respondsToSelector:@selector(count)] && [(NSArray *)object count] == 0));
|
||||
}
|
||||
@end
|
||||
@implementation NSDictionary (KAKit)
|
||||
-(NSString*) jsonString {
|
||||
|
||||
@try {
|
||||
// can not serialization, return a value is null array string
|
||||
if (![NSJSONSerialization isValidJSONObject:self]) {
|
||||
return @"[]";
|
||||
}
|
||||
} @catch (NSException *exception) {
|
||||
return @"[]";
|
||||
} @finally {}
|
||||
|
||||
NSError *error;
|
||||
NSData *jsonData;
|
||||
@try {
|
||||
jsonData = [NSJSONSerialization dataWithJSONObject:self
|
||||
options:kNilOptions
|
||||
error:&error];
|
||||
} @catch (NSException *exception) {
|
||||
return @"{}";
|
||||
} @finally {}
|
||||
|
||||
if (!jsonData) {
|
||||
return @"{}";
|
||||
} else {
|
||||
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString*)jsonFilterString {
|
||||
|
||||
NSError *error;
|
||||
NSData *jsonData;
|
||||
|
||||
NSMutableDictionary *extraDictM = [NSMutableDictionary dictionaryWithDictionary:self[kATUnityCheckLoadModelAdInfoKey]];
|
||||
NSMutableDictionary *extraDataTemp = [NSMutableDictionary dictionary];
|
||||
NSMutableDictionary *extraDataDictM = [NSMutableDictionary dictionaryWithDictionary:self[kATUnityCheckLoadModelAdInfoKey][kATUnityUserExtraDataKey]];
|
||||
for (NSString *key in extraDataDictM.allKeys) {
|
||||
if ([extraDataDictM[key] isKindOfClass:[NSString class]] || [extraDataDictM[key] isKindOfClass:[NSNumber class]]) {
|
||||
[extraDataTemp setValue:extraDataDictM[key] forKey:key];
|
||||
}
|
||||
}
|
||||
if ([extraDataTemp count]) {
|
||||
[extraDictM setValue:extraDataTemp forKey:kATUnityUserExtraDataKey];
|
||||
} else {
|
||||
[extraDictM removeObjectForKey:kATUnityUserExtraDataKey];
|
||||
}
|
||||
|
||||
NSMutableDictionary *jsonDictM = [NSMutableDictionary dictionaryWithDictionary:self];
|
||||
[jsonDictM setValue:extraDictM forKey:kATUnityCheckLoadModelAdInfoKey];
|
||||
|
||||
@try {
|
||||
jsonData = [NSJSONSerialization dataWithJSONObject:jsonDictM
|
||||
options:kNilOptions
|
||||
error:&error];
|
||||
} @catch (NSException *exception) {
|
||||
return @"{}";
|
||||
} @finally {}
|
||||
|
||||
if (!jsonData) {
|
||||
return @"{}";
|
||||
} else {
|
||||
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(BOOL)containsObjectForKey:(id)key {
|
||||
return [self.allKeys containsObject:key];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSArray (KAKit)
|
||||
-(NSString*) jsonString {
|
||||
NSError *error;
|
||||
NSData *jsonData;
|
||||
@try {
|
||||
jsonData = [NSJSONSerialization dataWithJSONObject:self
|
||||
options:kNilOptions
|
||||
error:&error];
|
||||
} @catch (NSException *exception) {
|
||||
return @"[]";
|
||||
} @finally {}
|
||||
|
||||
if (!jsonData) {
|
||||
return @"[]";
|
||||
} else {
|
||||
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString*)jsonFilterString {
|
||||
|
||||
NSError *error;
|
||||
NSData *jsonData;
|
||||
|
||||
NSMutableArray *filterArrayM = [NSMutableArray arrayWithCapacity:self.count];
|
||||
for (NSDictionary *adTempDict in self) {
|
||||
|
||||
NSMutableDictionary *extraDictM = [NSMutableDictionary dictionaryWithDictionary:adTempDict];
|
||||
NSMutableDictionary *extraDataTemp = [NSMutableDictionary dictionary];
|
||||
NSMutableDictionary *extraDataDictM = [NSMutableDictionary dictionaryWithDictionary:adTempDict[kATUnityUserExtraDataKey]];
|
||||
for (NSString *key in extraDataDictM.allKeys) {
|
||||
if ([extraDataDictM[key] isKindOfClass:[NSString class]] || [extraDataDictM[key] isKindOfClass:[NSNumber class]]) {
|
||||
[extraDataTemp setValue:extraDataDictM[key] forKey:key];
|
||||
}
|
||||
}
|
||||
if ([extraDataTemp count]) {
|
||||
[extraDictM setValue:extraDataTemp forKey:kATUnityUserExtraDataKey];
|
||||
} else {
|
||||
[extraDictM removeObjectForKey:kATUnityUserExtraDataKey];
|
||||
}
|
||||
[filterArrayM addObject:extraDictM];
|
||||
}
|
||||
|
||||
@try {
|
||||
jsonData = [NSJSONSerialization dataWithJSONObject:filterArrayM
|
||||
options:kNilOptions
|
||||
error:&error];
|
||||
} @catch (NSException *exception) {
|
||||
return @"[]";
|
||||
} @finally {}
|
||||
|
||||
if (!jsonData) {
|
||||
return @"[]";
|
||||
} else {
|
||||
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSData(ATKit)
|
||||
+(instancetype) dataWithUTF8String:(const char*)string {
|
||||
return [[NSString stringWithUTF8String:string] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
@end
|
||||
@implementation UIColor (Hex)
|
||||
// 透明度固定为1,以0x开头的十六进制转换成的颜色
|
||||
+ (UIColor*) colorWithHex:(long)hexColor;
|
||||
{
|
||||
return [UIColor colorWithHex:hexColor alpha:1.];
|
||||
}
|
||||
// 0x开头的十六进制转换成的颜色,透明度可调整
|
||||
+ (UIColor *)colorWithHex:(long)hexColor alpha:(float)opacity
|
||||
{
|
||||
float red = ((float)((hexColor & 0xFF0000) >> 16))/255.0;
|
||||
float green = ((float)((hexColor & 0xFF00) >> 8))/255.0;
|
||||
float blue = ((float)(hexColor & 0xFF))/255.0;
|
||||
return [UIColor colorWithRed:red green:green blue:blue alpha:opacity];
|
||||
}
|
||||
// 颜色转换三:iOS中十六进制的颜色(以#开头)转换为UIColor
|
||||
+ (UIColor *) colorWithHexString: (NSString *)color
|
||||
{
|
||||
NSString *cString = [[color stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
|
||||
|
||||
// String should be 6 or 8 characters
|
||||
if ([cString length] < 6) {
|
||||
return [UIColor clearColor];
|
||||
}
|
||||
|
||||
// 判断前缀并剪切掉
|
||||
if ([cString hasPrefix:@"0X"])
|
||||
cString = [cString substringFromIndex:2];
|
||||
if ([cString hasPrefix:@"#"])
|
||||
cString = [cString substringFromIndex:1];
|
||||
if ([cString length] != 6)
|
||||
return [UIColor clearColor];
|
||||
|
||||
// 从六位数值中找到RGB对应的位数并转换
|
||||
NSRange range;
|
||||
range.location = 0;
|
||||
range.length = 2;
|
||||
|
||||
//R、G、B
|
||||
NSString *rString = [cString substringWithRange:range];
|
||||
|
||||
range.location = 2;
|
||||
NSString *gString = [cString substringWithRange:range];
|
||||
|
||||
range.location = 4;
|
||||
NSString *bString = [cString substringWithRange:range];
|
||||
|
||||
// Scan values
|
||||
unsigned int r, g, b;
|
||||
[[NSScanner scannerWithString:rString] scanHexInt:&r];
|
||||
[[NSScanner scannerWithString:gString] scanHexInt:&g];
|
||||
[[NSScanner scannerWithString:bString] scanHexInt:&b];
|
||||
|
||||
return [UIColor colorWithRed:((float) r / 255.0f) green:((float) g / 255.0f) blue:((float) b / 255.0f) alpha:1.0f];
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a35d662bebf58447dbef58e5ac1e66c2
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// ATUnityWrapper.h
|
||||
// ATSDK
|
||||
//
|
||||
// Created by Martin Lau on 08/08/2018.
|
||||
// Copyright © 2018 Martin Lau. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef ATUnityWrapper_h
|
||||
#define ATUnityWrapper_h
|
||||
@protocol ATUnityWrapper<NSObject>
|
||||
+(instancetype) sharedInstance;
|
||||
@optional
|
||||
-(void) setCallBack:(void(*)(const char*, const char *))callback forKey:(NSString*)key;
|
||||
-(void) removeCallbackForKey:(NSString*)key;
|
||||
-(void(*)(const char*, const char *)) callbackForKey:(NSString*)key;
|
||||
@end
|
||||
|
||||
#endif /* ATUnityWrapper_h */
|
||||
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcccdfe3bb85548f2881247ba8effda5
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63ad3d5c2457e4cc0a4ec3cb55871ab0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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: 5c2551e3191c44d8a8c60bb3b9a405cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+219
@@ -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"]);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d08bff91e9f04e70a5d9b9cd12246c2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+263
@@ -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});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 711645adb26aa4e719452c22c119860a
|
||||
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(string debugKey)
|
||||
{
|
||||
Debug.Log("Unity:ATManager::showDebuggerUI()");
|
||||
ATUnityCBridge.SendMessageToC("ATUnityManager", "showDebuggerUI:", new object[] {debugKey});
|
||||
}
|
||||
|
||||
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: 03eb4e943127141c59f535e435de167a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+200
@@ -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"]);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user