diff --git a/Assets/ThinkupTpnPlugin.meta b/Assets/ThinkupTpnPlugin.meta new file mode 100644 index 0000000..28a53ff --- /dev/null +++ b/Assets/ThinkupTpnPlugin.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: eeff680af0e614c868711d401f3a1cc6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds.meta new file mode 100644 index 0000000..0ed6558 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6906a18bbd98b4ba8ae1df69e7a45531 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api.meta new file mode 100644 index 0000000..d4aa59c --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6e450fee0707f449a85d8d46819fd720 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATAdEventArgs.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATAdEventArgs.cs new file mode 100644 index 0000000..95e6d08 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATAdEventArgs.cs @@ -0,0 +1,218 @@ + +using System; +using System.Collections; +using AnyThinkAds.Api; + +namespace AnyThinkAds.Api +{ + + public class ATAdEventArgs + { + public String placementId { get; } + public ATCallbackInfo callbackInfo { get; } + public bool isTimeout { get; } + + public bool isDeeplinkSucceed { get; } + + public ATAdEventArgs(string id, string callbackJson = "", bool timeout = false, bool isDeeplinkSucceess = false) + { + placementId = id; + callbackInfo = new ATCallbackInfo(callbackJson); + isTimeout = timeout; + isDeeplinkSucceed = isDeeplinkSucceess; + } + + // public ATAdEventArgs(String id, String callbackJson) + // { + // placementId = id; + // callbackInfo = new ATCallbackInfo(callbackJson); + // } + } + + public class ATAdErrorEventArgs : ATAdEventArgs + { + public String errorMessage { get; } + public String errorCode { get; } + + public ATAdErrorEventArgs(String placementId, String code, String message) + : base(placementId) + { + errorMessage = message; + errorCode = code; + } + + public ATAdErrorEventArgs(String placementId, String callbackJson, String code, String message) + : base(placementId, callbackJson) + { + errorMessage = message; + errorCode = code; + } + } + + public class ATAdProgressEventArgs : ATAdEventArgs + { + public int adProgress { get; } + + public ATAdProgressEventArgs(String placementId, String callbackJson, int progress) + : base(placementId, callbackJson) + { + adProgress = progress; + } + } + + public class ATAdRewardEventArgs : ATAdEventArgs + { + public bool isRewarded { get; } + + public ATAdRewardEventArgs(String placementId, String callbackJson, bool doReward) + : base(placementId, callbackJson) + { + isRewarded = doReward; + } + } + + + public interface IHCommonEvents + { + // triggers when the ad has been succesfully loaded + event EventHandler onAdLoadEvent; + + // triggers when the ad has failed to load + event EventHandler onAdLoadFailureEvent; + + // triggers when a the ad has started to load + event EventHandler onAdSourceAttemptEvent; + + // triggers when a the ad has finished to load + event EventHandler onAdSourceFilledEvent; + + // triggers when a the ad has started to load + event EventHandler onAdSourceLoadFailureEvent; + + // triggers when a the ad has started to load + event EventHandler onAdSourceBiddingAttemptEvent; + + // triggers when a the ad has started to load + event EventHandler onAdSourceBiddingFilledEvent; + + // triggers when a the ad has started to load + event EventHandler onAdSourceBiddingFailureEvent; + } + + + public interface IATBannerEvents: IHCommonEvents + { + // triggers when a banner ad generates an impression + event EventHandler onAdImpressEvent; + + // triggers when the user clicks a banner ad + event EventHandler onAdClickEvent; + + // triggers when the ad refreshes + event EventHandler onAdAutoRefreshEvent; + + // triggers when the ad fails to auto refresh + event EventHandler onAdAutoRefreshFailureEvent; + + // triggers when the banner ad is closed + event EventHandler onAdCloseEvent; + + // triggers when the users closes the ad via the button + event EventHandler onAdCloseButtonTappedEvent; + } + + public interface IATInterstitialAdEvents : IHCommonEvents + { + // called when the ad is shown + event EventHandler onAdShowEvent; + + // called if the ad has failed to be shown + event EventHandler onAdShowFailureEvent; + + // called when the ad is closed + event EventHandler onAdCloseEvent; + + // called when an user has clicked an ad + event EventHandler onAdClickEvent; + + // called when a video ad has started playing + event EventHandler onAdVideoStartEvent; + + // called if an ad video has failed to be displayed + event EventHandler onAdVideoFailureEvent; + + // called when ad video has finished + event EventHandler onAdVideoEndEvent; + } + + public interface IATNativeAdEvents : IHCommonEvents + { + // triggers when the ad generates an impression + event EventHandler onAdImpressEvent; + + // triggers when the user clicks the ad + event EventHandler onAdClickEvent; + + // triggers when the ad video starts + event EventHandler onAdVideoStartEvent; + + // triggers when the ad video ends + event EventHandler onAdVideoEndEvent; + + // triggers if the ad progresses + event EventHandler onAdVideoProgressEvent; + + // triggers when the ad is closed + event EventHandler onAdCloseEvent; + } + + public interface IATRewardedVideoEvents : IHCommonEvents + { + // triggers on video start + event EventHandler onAdVideoStartEvent; + + // triggers on video end + event EventHandler onAdVideoEndEvent; + + // triggers if the video fails to play + event EventHandler onAdVideoFailureEvent; + + // triggers when the user has closed the ad + event EventHandler onAdVideoCloseEvent; + + // triggers when the user has clicked the ad + event EventHandler onAdClickEvent; + + // triggers when the user has finsihed watching the ad and should be rewarded + event EventHandler onRewardEvent; + + event EventHandler onPlayAgainStart; + + event EventHandler onPlayAgainEnd; + + event EventHandler onPlayAgainFailure; + + event EventHandler onPlayAgainClick; + + event EventHandler onPlayAgainReward; + } + + public interface IATSplashEvents : IHCommonEvents + { + // called when the ad is shown + event EventHandler onAdShowEvent; + + // called if the ad has failed to be shown + event EventHandler onAdShowFailureEvent; + + // called when the ad is closed + event EventHandler onAdCloseEvent; + + // called when an user has clicked an ad + event EventHandler onAdClickEvent; + + event EventHandler onAdLoadTimeoutEvent; + event EventHandler onDeeplinkEvent; + event EventHandler onDownloadConfirmEvent; + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATAdEventArgs.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATAdEventArgs.cs.meta new file mode 100644 index 0000000..4431858 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATAdEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1873e4bb153b945a18427021948855ea +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATBannerAd.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATBannerAd.cs new file mode 100644 index 0000000..d5509ec --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATBannerAd.cs @@ -0,0 +1,130 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System.Reflection; +using System; + +using AnyThinkAds.Common; +using AnyThinkAds.ThirdParty.LitJson; + +namespace AnyThinkAds.Api +{ + public class ATBannerAdLoadingExtra + { + public static readonly string kATBannerAdLoadingExtraBannerAdSize = "banner_ad_size"; + public static readonly string kATBannerAdLoadingExtraBannerAdSizeStruct = "banner_ad_size_struct"; + public static readonly string kATBannerAdSizeUsesPixelFlagKey = "uses_pixel"; + public static readonly string kATBannerAdShowingPisitionTop = "top"; + public static readonly string kATBannerAdShowingPisitionBottom = "bottom"; + + //Deprecated in v5.7.3 + public static readonly string kATBannerAdLoadingExtraInlineAdaptiveWidth = "inline_adaptive_width"; + public static readonly string kATBannerAdLoadingExtraInlineAdaptiveOrientation = "inline_adaptive_orientation"; + public static readonly int kATBannerAdLoadingExtraInlineAdaptiveOrientationCurrent = 0; + public static readonly int kATBannerAdLoadingExtraInlineAdaptiveOrientationPortrait = 1; + public static readonly int kATBannerAdLoadingExtraInlineAdaptiveOrientationLandscape = 2; + //Deprecated in v5.7.3 + + public static readonly string kATBannerAdLoadingExtraAdaptiveWidth = "adaptive_width"; + public static readonly string kATBannerAdLoadingExtraAdaptiveOrientation = "adaptive_orientation"; + public static readonly int kATBannerAdLoadingExtraAdaptiveOrientationCurrent = 0; + public static readonly int kATBannerAdLoadingExtraAdaptiveOrientationPortrait = 1; + public static readonly int kATBannerAdLoadingExtraAdaptiveOrientationLandscape = 2; + + } + public class ATBannerAd + { + private static readonly ATBannerAd instance = new ATBannerAd(); + public IATBannerAdClient client; + + private ATBannerAd() + { + client = GetATBannerAdClient(); + + } + + public static ATBannerAd Instance + { + get + { + return instance; + } + } + + /** + API + */ + public void loadBannerAd(string placementId, Dictionary pairs) + { + if (pairs != null && pairs.ContainsKey(ATBannerAdLoadingExtra.kATBannerAdLoadingExtraBannerAdSize)) + { + client.loadBannerAd(placementId, JsonMapper.ToJson(pairs)); + } + else if (pairs != null && pairs.ContainsKey(ATBannerAdLoadingExtra.kATBannerAdLoadingExtraBannerAdSizeStruct)) + { + ATSize size = (ATSize)(pairs[ATBannerAdLoadingExtra.kATBannerAdLoadingExtraBannerAdSizeStruct]); + pairs.Add(ATBannerAdLoadingExtra.kATBannerAdLoadingExtraBannerAdSize, size.width + "x" + size.height); + pairs.Add(ATBannerAdLoadingExtra.kATBannerAdSizeUsesPixelFlagKey, size.usesPixel); + + //Dictionary newPaires = new Dictionary { { ATBannerAdLoadingExtra.kATBannerAdLoadingExtraBannerAdSize, size.width + "x" + size.height }, { ATBannerAdLoadingExtra.kATBannerAdSizeUsesPixelFlagKey, size.usesPixel } }; + client.loadBannerAd(placementId, JsonMapper.ToJson(pairs)); + } + else + { + client.loadBannerAd(placementId, JsonMapper.ToJson(pairs)); + } + + } + + public string checkAdStatus(string placementId) + { + return client.checkAdStatus(placementId); + } + + public string getValidAdCaches(string placementId) + { + return client.getValidAdCaches(placementId); + } + + + public void showBannerAd(string placementId, ATRect rect) + { + client.showBannerAd(placementId, rect, ""); + } + + public void showBannerAd(string placementId, ATRect rect, Dictionary pairs) + { + client.showBannerAd(placementId, rect, JsonMapper.ToJson(pairs)); + } + + public void showBannerAd(string placementId, string position) + { + client.showBannerAd(placementId, position, ""); + } + + public void showBannerAd(string placementId, string position, Dictionary pairs) + { + client.showBannerAd(placementId, position, JsonMapper.ToJson(pairs)); + } + + public void showBannerAd(string placementId) + { + client.showBannerAd(placementId); + } + + public void hideBannerAd(string placementId) + { + client.hideBannerAd(placementId); + } + + public void cleanBannerAd(string placementId) + { + client.cleanBannerAd(placementId); + } + + public IATBannerAdClient GetATBannerAdClient() + { + return AnyThinkAds.ATAdsClientFactory.BuildBannerAdClient(); + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATBannerAd.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATBannerAd.cs.meta new file mode 100644 index 0000000..714158f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATBannerAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6a3de7186fc0c4769b4be98aa9d6dd2b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATBannerAdListener.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATBannerAdListener.cs new file mode 100644 index 0000000..80692ef --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATBannerAdListener.cs @@ -0,0 +1,57 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace AnyThinkAds.Api +{ + public interface ATBannerAdListener + { + /*** + * 广告请求成功(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdLoad(string placementId); + /*** + * 广告请求失败(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdLoadFail(string placementId, string code, string message); + /*** + * 广告展示(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdImpress(string placementId, ATCallbackInfo callbackInfo); + /** + * 广告点击(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdClick(string placementId, ATCallbackInfo callbackInfo); + /** + * 广告自动刷新(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdAutoRefresh(string placementId, ATCallbackInfo callbackInfo); + /** + *广告自动刷新失败(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdAutoRefreshFail(string placementId, string code, string message); + /** + *广告关闭;某些厂商不支持(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdClose(string placementId); + /** + *广告关闭;某些厂商不支持(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdCloseButtonTapped(string placementId, ATCallbackInfo callbackInfo); + + + void startLoadingADSource(string placementId, ATCallbackInfo callbackInfo); + + void finishLoadingADSource(string placementId, ATCallbackInfo callbackInfo); + + void failToLoadADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message); + + void startBiddingADSource(string placementId, ATCallbackInfo callbackInfo); + + void finishBiddingADSource(string placementId, ATCallbackInfo callbackInfo); + + void failBiddingADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message); + + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATBannerAdListener.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATBannerAdListener.cs.meta new file mode 100644 index 0000000..df5576d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATBannerAdListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 14409d00636a347a38d6c005ec2b104c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATCallbackInfo.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATCallbackInfo.cs new file mode 100644 index 0000000..3d320f3 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATCallbackInfo.cs @@ -0,0 +1,189 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using AnyThinkAds.ThirdParty.LitJson; + +namespace AnyThinkAds.Api +{ + public class ATCallbackInfo + { + + public readonly int network_firm_id; + public readonly string adsource_id; + public readonly int adsource_index; + public readonly double adsource_price; + public readonly int adsource_isheaderbidding; + + public readonly string id; + public readonly double publisher_revenue; + public readonly string currency; + public readonly string country; + public readonly string adunit_id; + + public readonly string adunit_format; + public readonly string precision; + public readonly string network_type; + public readonly string network_placement_id; + public readonly int ecpm_level; + + public readonly int segment_id; + public readonly string scenario_id; + public readonly string scenario_reward_name; + public readonly int scenario_reward_number; + + public readonly string sub_channel; + public readonly string channel; + public readonly Dictionary custom_rule; + + public readonly Dictionary ext_info; + public readonly Dictionary user_load_extra_data; + public readonly int abtest_id; + + public readonly string reward_custom_data; + public readonly int placement_type; + public readonly string shared_placement_id; + public readonly string bid_floor; + public readonly int dismiss_type; + public readonly int ad_source_type; + public readonly string ad_source_custom_ext; + public readonly string network_name; + public readonly string show_custom_ext; + public readonly string e_c; + public readonly int s_id; + + private string callbackJson; + + public ATCallbackInfo(string callbackJson) + { + try + { + this.callbackJson = callbackJson; + + + JsonData jsonData = JsonMapper.ToObject(callbackJson); + + network_firm_id = int.Parse(jsonData.ContainsKey("network_firm_id") ? jsonData["network_firm_id"].ToString() : "0"); + adsource_id = jsonData.ContainsKey("adsource_id") ? (string)jsonData["adsource_id"] : ""; + adsource_index = int.Parse(jsonData.ContainsKey("adsource_index") ? jsonData["adsource_index"].ToString() : "-1"); + adsource_price = double.Parse(jsonData.ContainsKey("adsource_price") ? jsonData["adsource_price"].ToString() : "0"); + + adsource_isheaderbidding = 0; + if (jsonData.ContainsKey("adsource_isheaderbidding")) { + adsource_isheaderbidding = int.Parse(jsonData.ContainsKey("adsource_isheaderbidding") ? jsonData["adsource_isheaderbidding"].ToString() : "0"); + } + + id = jsonData.ContainsKey("id") ? (string)jsonData["id"] : ""; + publisher_revenue = double.Parse(jsonData.ContainsKey("publisher_revenue") ? jsonData["publisher_revenue"].ToString() : "0"); + currency = jsonData.ContainsKey("currency") ? (string)jsonData["currency"] : ""; + country = jsonData.ContainsKey("country") ? (string)jsonData["country"] : ""; + + adunit_format = jsonData.ContainsKey("adunit_format") ? (string)jsonData["adunit_format"] : ""; + adunit_id = jsonData.ContainsKey("adunit_id") ? (string)jsonData["adunit_id"] : ""; + + precision = jsonData.ContainsKey("precision") ? (string)jsonData["precision"] : ""; + + network_type = jsonData.ContainsKey("network_type") ? (string)jsonData["network_type"] : ""; + + network_placement_id = jsonData.ContainsKey("network_placement_id") ? (string)jsonData["network_placement_id"] : ""; + ecpm_level = int.Parse(jsonData.ContainsKey("ecpm_level") ? jsonData["ecpm_level"].ToString() : "0"); + abtest_id = int.Parse(jsonData.ContainsKey("abtest_id") ? jsonData["abtest_id"].ToString() : "0"); + segment_id = int.Parse(jsonData.ContainsKey("segment_id") ? jsonData["segment_id"].ToString() : "0"); + scenario_id = jsonData.ContainsKey("scenario_id") ? (string)jsonData["scenario_id"] : "";// RewardVideo & Interstitial + + if (jsonData.ContainsKey("user_load_extra_data")) { + user_load_extra_data = JsonMapper.ToObject>(jsonData["user_load_extra_data"].ToJson()); + } + + scenario_reward_name = jsonData.ContainsKey("scenario_reward_name") ? (string)jsonData["scenario_reward_name"] : ""; + scenario_reward_number = int.Parse(jsonData.ContainsKey("scenario_reward_number") ? jsonData["scenario_reward_number"].ToString() : "0"); + + channel = jsonData.ContainsKey("channel") ? (string)jsonData["channel"] : ""; + sub_channel = jsonData.ContainsKey("sub_channel") ? (string)jsonData["sub_channel"] : ""; + custom_rule = jsonData.ContainsKey("custom_rule") ? JsonMapper.ToObject>(jsonData["custom_rule"].ToJson()) : null; + ext_info = jsonData.ContainsKey("ext_info") ? JsonMapper.ToObject>(jsonData["ext_info"].ToJson()) : null; + + reward_custom_data = jsonData.ContainsKey("reward_custom_data") ? (string)jsonData["reward_custom_data"] : ""; + + placement_type = int.Parse(jsonData.ContainsKey("placement_type") ? jsonData["placement_type"].ToString() : "0"); + shared_placement_id = jsonData.ContainsKey("shared_placement_id") ? jsonData["shared_placement_id"].ToString() : ""; + bid_floor = jsonData.ContainsKey("bid_floor") ? jsonData["bid_floor"].ToString() : ""; + dismiss_type = int.Parse(jsonData.ContainsKey("dismiss_type") ? jsonData["dismiss_type"].ToString() : "0"); + ad_source_type = int.Parse(jsonData.ContainsKey("ad_source_type") ? jsonData["ad_source_type"].ToString() : "0"); + ad_source_custom_ext = jsonData.ContainsKey("ad_source_custom_ext") ? jsonData["ad_source_custom_ext"].ToString() : ""; + network_name = jsonData.ContainsKey("network_name") ? jsonData["network_name"].ToString() : ""; + show_custom_ext = jsonData.ContainsKey("show_custom_ext") ? jsonData["show_custom_ext"].ToString() : ""; + e_c = jsonData.ContainsKey("e_c") ? jsonData["e_c"].ToString() : ""; + s_id = int.Parse(jsonData.ContainsKey("s_id") ? jsonData["s_id"].ToString() : "0"); + } + catch (System.Exception e) { + System.Console.WriteLine("Exception caught: {0}", e); + } + } + + public string getOriginJSONString() + { + return callbackJson; + } + + public Dictionary toAdsourceDictionary() + { + Dictionary dataDictionary = new Dictionary(); + + dataDictionary.Add("adsource_id", adsource_id); + dataDictionary.Add("adsource_price", adsource_price); + dataDictionary.Add("adunit_id", adunit_id); + dataDictionary.Add("currency", currency); + dataDictionary.Add("network_firm_id",network_firm_id); + dataDictionary.Add("network_placement_id",network_placement_id); + return dataDictionary; + + } + + public Dictionary toDictionary() + { + Dictionary dataDictionary = new Dictionary(); + + dataDictionary.Add("network_firm_id",network_firm_id); + dataDictionary.Add("adsource_id", adsource_id); + dataDictionary.Add("adsource_index", adsource_index); + dataDictionary.Add("adsource_price", adsource_price); + dataDictionary.Add("adsource_isheaderbidding", adsource_isheaderbidding); + dataDictionary.Add("id", id); + dataDictionary.Add("publisher_revenue", publisher_revenue); + dataDictionary.Add("currency", currency); + dataDictionary.Add("country", country); + dataDictionary.Add("adunit_id", adunit_id); + dataDictionary.Add("adunit_format", adunit_format); + dataDictionary.Add("precision", precision); + dataDictionary.Add("network_type", network_type); + dataDictionary.Add("network_placement_id",network_placement_id); + dataDictionary.Add("ecpm_level", ecpm_level); + dataDictionary.Add("segment_id", segment_id); + dataDictionary.Add("scenario_id", scenario_id); + dataDictionary.Add("user_load_extra_data", user_load_extra_data); + dataDictionary.Add("scenario_reward_name", scenario_reward_name); + dataDictionary.Add("scenario_reward_number", scenario_reward_number); + dataDictionary.Add("abtest_id", abtest_id); + + dataDictionary.Add("sub_channel", sub_channel); + dataDictionary.Add("channel", channel); + dataDictionary.Add("custom_rule", custom_rule); + dataDictionary.Add("ext_info", ext_info); + dataDictionary.Add("reward_custom_data", reward_custom_data); + dataDictionary.Add("placement_type", placement_type); + dataDictionary.Add("shared_placement_id", shared_placement_id); + dataDictionary.Add("bid_floor", bid_floor); + dataDictionary.Add("dismiss_type", dismiss_type); + dataDictionary.Add("ad_source_type", ad_source_type); + dataDictionary.Add("ad_source_custom_ext", ad_source_custom_ext); + dataDictionary.Add("network_name", network_name); + dataDictionary.Add("show_custom_ext", show_custom_ext); + dataDictionary.Add("e_c", e_c); + dataDictionary.Add("s_id", s_id); + + return dataDictionary; + } + + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATCallbackInfo.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATCallbackInfo.cs.meta new file mode 100644 index 0000000..4004896 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATCallbackInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8829d744b2f8b445495d55152f9ffc35 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATConst.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATConst.cs new file mode 100644 index 0000000..4b52e58 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATConst.cs @@ -0,0 +1,25 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace AnyThinkAds.Api +{ + public class ATConst { + public const string ADAPTIVE_HEIGHT = "AdaptiveHeight";//value is string + public const string ADAPTIVE_HEIGHT_YES = "1"; + public const string POSITION = "Position";//value is string + public const string POSITION_TOP = "Top"; + public const string POSITION_BOTTOM = "Bottom"; + + + public const string SCENARIO = "Scenario";//value is string + public const string USERID_KEY = "UserId";//value is string + public const string USER_EXTRA_DATA = "UserExtraData"; //value is string + public const string USE_REWARDED_VIDEO_AS_INTERSTITIAL = "UseRewardedVideoAsInterstitial";//value is string + public const string USE_REWARDED_VIDEO_AS_INTERSTITIAL_YES = "1"; + public const string USE_REWARDED_VIDEO_AS_INTERSTITIAL_NO = "0"; + + public const string WIDTH = "Width";//value is string + public const string HEIGHT = "Height";//value is string + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATConst.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATConst.cs.meta new file mode 100644 index 0000000..a5aa156 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATConst.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 81be0ce7c637b4a7098f6c0d53904a2e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATDownloadAdListener.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATDownloadAdListener.cs new file mode 100644 index 0000000..9f8602f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATDownloadAdListener.cs @@ -0,0 +1,21 @@ + + +namespace AnyThinkAds.Api +{ + public interface ATDownloadAdListener + { + + void onDownloadStart(string placementId, ATCallbackInfo callbackInfo, long totalBytes, long currBytes, string fileName, string appName); + + void onDownloadUpdate(string placementId, ATCallbackInfo callbackInfo, long totalBytes, long currBytes, string fileName, string appName); + + void onDownloadPause(string placementId, ATCallbackInfo callbackInfo, long totalBytes, long currBytes, string fileName, string appName); + + void onDownloadFinish(string placementId, ATCallbackInfo callbackInfo, long totalBytes, string fileName, string appName); + + void onDownloadFail(string placementId, ATCallbackInfo callbackInfo, long totalBytes, long currBytes, string fileName, string appName); + + void onInstalled(string placementId, ATCallbackInfo callbackInfo, string fileName, string appName); + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATDownloadAdListener.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATDownloadAdListener.cs.meta new file mode 100644 index 0000000..b0466b0 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATDownloadAdListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6bbee7503778a43b0b9120f7a550347a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATDownloadManager.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATDownloadManager.cs new file mode 100644 index 0000000..0c6c51b --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATDownloadManager.cs @@ -0,0 +1,36 @@ + +using AnyThinkAds.Common; + + +namespace AnyThinkAds.Api +{ + public class ATDownloadManager + { + private static readonly ATDownloadManager instance = new ATDownloadManager(); + private IATDownloadClient client; + + private ATDownloadManager() + { + client = GetATDownloadClient(); + } + + public static ATDownloadManager Instance + { + get + { + return instance; + } + } + + public void setListener(ATDownloadAdListener listener) + { + client.setListener(listener); + } + + public IATDownloadClient GetATDownloadClient() + { + return AnyThinkAds.ATAdsClientFactory.BuildDownloadClient(); + } + + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATDownloadManager.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATDownloadManager.cs.meta new file mode 100644 index 0000000..90a2fa6 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATDownloadManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 12983d140829a46f08eeaf46eb36280f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAd.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAd.cs new file mode 100644 index 0000000..97d8d70 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAd.cs @@ -0,0 +1,89 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System.Reflection; +using System; + +using AnyThinkAds.Common; +using AnyThinkAds.ThirdParty.LitJson; + +namespace AnyThinkAds.Api +{ + public class ATInterstitialAdLoadingExtra + { + public static readonly string kATInterstitialAdLoadingExtraInterstitialAdSize = "interstitial_ad_size"; + public static readonly string kATInterstitialAdLoadingExtraInterstitialAdSizeStruct = "interstitial_ad_size_struct"; + public static readonly string kATInterstitialAdSizeUsesPixelFlagKey = "uses_pixel"; + } + + public class ATInterstitialAd + { + private static readonly ATInterstitialAd instance = new ATInterstitialAd(); + public IATInterstitialAdClient client; + + private ATInterstitialAd() + { + client = GetATInterstitialAdClient(); + } + + public static ATInterstitialAd Instance + { + get + { + return instance; + } + } + + public void loadInterstitialAd(string placementId, Dictionary pairs) + { + if (pairs != null && pairs.ContainsKey(ATInterstitialAdLoadingExtra.kATInterstitialAdLoadingExtraInterstitialAdSizeStruct)) + { + ATSize size = (ATSize)(pairs[ATInterstitialAdLoadingExtra.kATInterstitialAdLoadingExtraInterstitialAdSizeStruct]); + pairs.Add(ATInterstitialAdLoadingExtra.kATInterstitialAdLoadingExtraInterstitialAdSize, size.width + "x" + size.height); + pairs.Add(ATInterstitialAdLoadingExtra.kATInterstitialAdSizeUsesPixelFlagKey, size.usesPixel); + + client.loadInterstitialAd(placementId, JsonMapper.ToJson(pairs)); + } else + { + client.loadInterstitialAd(placementId, JsonMapper.ToJson(pairs)); + } + } + + + public bool hasInterstitialAdReady(string placementId) + { + return client.hasInterstitialAdReady(placementId); + } + public void entryScenarioWithPlacementID(string placementId, string scenarioID) + { + client.entryScenarioWithPlacementID(placementId,scenarioID); + } + + + public string checkAdStatus(string placementId) + { + return client.checkAdStatus(placementId); + } + + public string getValidAdCaches(string placementId) + { + return client.getValidAdCaches(placementId); + } + + public void showInterstitialAd(string placementId) + { + client.showInterstitialAd(placementId, JsonMapper.ToJson(new Dictionary())); + } + + public void showInterstitialAd(string placementId, Dictionary pairs) + { + client.showInterstitialAd(placementId, JsonMapper.ToJson(pairs)); + } + + public IATInterstitialAdClient GetATInterstitialAdClient() + { + return AnyThinkAds.ATAdsClientFactory.BuildInterstitialAdClient(); + } + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAd.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAd.cs.meta new file mode 100644 index 0000000..43eefa9 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5156b3afa9c234defa31b9e43c21309c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAdListener.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAdListener.cs new file mode 100644 index 0000000..ee49d24 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAdListener.cs @@ -0,0 +1,74 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + + +namespace AnyThinkAds.Api +{ + public interface ATInterstitialAdListener + { + /*** + * 加载广告成功(注意:对于Android来说,所有回调方法均不在Unity的主线程) + * @param placementId 广告位id + */ + void onInterstitialAdLoad(string placementId); + /*** + * 加载广告失败(注意:对于Android来说,所有回调方法均不在Unity的主线程) + * @param placementId 广告位id + * @param code 错误码 + * @param message 错误信息 + */ + void onInterstitialAdLoadFail(string placementId, string code, string message); + /*** + * 广告展示(注意:对于Android来说,所有回调方法均不在Unity的主线程) + * @param placementId 广告位id + */ + void onInterstitialAdShow(string placementId, ATCallbackInfo callbackInfo); + /*** + * 广告展示失败(注意:对于Android来说,所有回调方法均不在Unity的主线程) + * @param placementId 广告位id + */ + void onInterstitialAdFailedToShow(string placementId); + /*** + * 广告关闭(注意:对于Android来说,所有回调方法均不在Unity的主线程) + * @param placementId 广告位id + */ + void onInterstitialAdClose(string placementId, ATCallbackInfo callbackInfo); + /*** + * 广告点击(注意:对于Android来说,所有回调方法均不在Unity的主线程) + * @param placementId 广告位id + */ + void onInterstitialAdClick(string placementId, ATCallbackInfo callbackInfo); + /** + *广告开始播放视频(注意:对于Android来说,所有回调方法均不在Unity的主线程) + * @param placementId 广告位id + */ + void onInterstitialAdStartPlayingVideo(string placementId, ATCallbackInfo callbackInfo); + /** + *广告视频播放结束(注意:对于Android来说,所有回调方法均不在Unity的主线程) + * @param placementId 广告位id + */ + void onInterstitialAdEndPlayingVideo(string placementId, ATCallbackInfo callbackInfo); + /** + *广告播放视频失败(注意:对于Android来说,所有回调方法均不在Unity的主线程) + * @param placementId 广告位id + * @param code 错误码 + * @param message 错误信息 + */ + void onInterstitialAdFailedToPlayVideo(string placementId, string code, string message); + + void startLoadingADSource(string placementId, ATCallbackInfo callbackInfo); + + void finishLoadingADSource(string placementId, ATCallbackInfo callbackInfo); + + void failToLoadADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message); + + void startBiddingADSource(string placementId, ATCallbackInfo callbackInfo); + + void finishBiddingADSource(string placementId, ATCallbackInfo callbackInfo); + + void failBiddingADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message); + + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAdListener.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAdListener.cs.meta new file mode 100644 index 0000000..729463c --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAdListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0d331dade788243748d28c8e34b8f7f5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAutoAd.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAutoAd.cs new file mode 100644 index 0000000..272336a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAutoAd.cs @@ -0,0 +1,97 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System.Reflection; +using System; + +using AnyThinkAds.Common; +using AnyThinkAds.ThirdParty.LitJson; + +namespace AnyThinkAds.Api +{ + + public class ATInterstitialAutoAd + { + private static readonly ATInterstitialAutoAd instance = new ATInterstitialAutoAd(); + public IATInterstitialAdClient client; + + private ATInterstitialAutoAd() + { + client = GetATInterstitialAdClient(); + } + + public static ATInterstitialAutoAd Instance + { + get + { + return instance; + } + } + + public IATInterstitialAdClient GetATInterstitialAdClient() + { + return AnyThinkAds.ATAdsClientFactory.BuildInterstitialAdClient(); + } + + + // auto + + public void addAutoLoadAdPlacementID(string[] placementIDList) + { + client.addAutoLoadAdPlacementID(placementIDList); + } + + public void removeAutoLoadAdPlacementID(string[] placementIDList) + { + if (placementIDList != null && placementIDList.Length > 0) + { + string placementIDListString = JsonMapper.ToJson(placementIDList); + client.removeAutoLoadAdPlacementID(placementIDListString); + Debug.Log("removeAutoLoadAdPlacementID, placementIDList === " + placementIDListString); + } + else + { + Debug.Log("removeAutoLoadAdPlacementID, placementIDList = null"); + } + } + + public string checkAutoAdStatus(string placementId) + { + return client.checkAutoAdStatus(placementId); + } + + public bool autoLoadInterstitialAdReadyForPlacementID(string placementId) + { + return client.autoLoadInterstitialAdReadyForPlacementID(placementId); + } + public string getAutoValidAdCaches(string placementId) + { + return client.getAutoValidAdCaches(placementId); + } + + public void setAutoLocalExtra(string placementId, Dictionary pairs) + { + client.setAutoLocalExtra(placementId, JsonMapper.ToJson(pairs)); + } + public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID) + { + client.entryAutoAdScenarioWithPlacementID(placementId, scenarioID); + } + + public void showAutoAd(string placementId) + { + client.showAutoAd(placementId, JsonMapper.ToJson(new Dictionary())); + } + + public void showAutoAd(string placementId, Dictionary pairs) + { + client.showAutoAd(placementId, JsonMapper.ToJson(pairs)); + } + + + + + + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAutoAd.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAutoAd.cs.meta new file mode 100644 index 0000000..9c10221 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATInterstitialAutoAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 53db171e8bdb94471b37886d51adb5d3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAd.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAd.cs new file mode 100644 index 0000000..7bd4ae6 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAd.cs @@ -0,0 +1,101 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System.Reflection; +using System; + +using AnyThinkAds.Common; +using AnyThinkAds.ThirdParty.LitJson; + + +namespace AnyThinkAds.Api +{ + public class ATNativeAdLoadingExtra + { + public static readonly string kATNativeAdLoadingExtraNativeAdSizeStruct = "native_ad_size_struct"; + public static readonly string kATNativeAdLoadingExtraNativeAdSize = "native_ad_size"; + public static readonly string kATNativeAdSizeUsesPixelFlagKey = "uses_pixel"; + } + + public class ATNativeAd + { + + private static readonly ATNativeAd instance = new ATNativeAd(); + public IATNativeAdClient client; + + public ATNativeAd(){ + client = GetATNativeAdClient(); + } + + public static ATNativeAd Instance + { + get + { + return instance; + } + } + + + public void loadNativeAd(string placementId, Dictionary pairs){ + if (pairs != null && pairs.ContainsKey(ATNativeAdLoadingExtra.kATNativeAdLoadingExtraNativeAdSizeStruct)) + { + ATSize size = (ATSize)(pairs[ATNativeAdLoadingExtra.kATNativeAdLoadingExtraNativeAdSizeStruct]); + pairs.Add(ATNativeAdLoadingExtra.kATNativeAdLoadingExtraNativeAdSize, size.width + "x" + size.height); + pairs.Add(ATNativeAdLoadingExtra.kATNativeAdSizeUsesPixelFlagKey, size.usesPixel); + } + client.loadNativeAd(placementId,JsonMapper.ToJson(pairs)); + } + + public bool hasAdReady(string placementId){ + return client.hasAdReady(placementId); + } + + public string checkAdStatus(string placementId) + { + return client.checkAdStatus(placementId); + } + + public string getValidAdCaches(string placementId) + { + return client.getValidAdCaches(placementId); + } + + + public void entryScenarioWithPlacementID(string placementId, string scenarioID) + { + client.entryScenarioWithPlacementID(placementId,scenarioID); + } + + public void renderAdToScene(string placementId, ATNativeAdView anyThinkNativeAdView){ + client.renderAdToScene(placementId, anyThinkNativeAdView, ""); + } + + public void renderAdToScene(string placementId, ATNativeAdView anyThinkNativeAdView, Dictionary pairs){ + client.renderAdToScene(placementId, anyThinkNativeAdView, JsonMapper.ToJson(pairs)); + } + + public void cleanAdView(string placementId, ATNativeAdView anyThinkNativeAdView){ + client.cleanAdView(placementId, anyThinkNativeAdView); + } + + public void onApplicationForces(string placementId, ATNativeAdView anyThinkNativeAdView){ + client.onApplicationForces(placementId, anyThinkNativeAdView); + } + + public void onApplicationPasue(string placementId, ATNativeAdView anyThinkNativeAdView){ + client.onApplicationPasue(placementId, anyThinkNativeAdView); + } + + public void cleanCache(string placementId){ + client.cleanCache(placementId); + } + + + + public IATNativeAdClient GetATNativeAdClient() + { + return AnyThinkAds.ATAdsClientFactory.BuildNativeAdClient(); + } + + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAd.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAd.cs.meta new file mode 100644 index 0000000..57fec26 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ff4a301239a2c463eb38ee921c41de3b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAdListener.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAdListener.cs new file mode 100644 index 0000000..cb9a052 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAdListener.cs @@ -0,0 +1,60 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace AnyThinkAds.Api +{ + public interface ATNativeAdListener + { + /*** + * 广告请求成功(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdLoaded(string placementId); + /*** + * 广告请求失败(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdLoadFail(string placementId, string code, string message); + /*** + * 广告展示(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdImpressed(string placementId, ATCallbackInfo callbackInfo); + /** + * 广告点击(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdClicked(string placementId, ATCallbackInfo callbackInfo); + /*** + * 视屏播放开始 如果有(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdVideoStart(string placementId); + /*** + * 视屏播放结束 如果有(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdVideoEnd(string placementId); + /*** + * 视屏播放进度 如果有(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdVideoProgress(string placementId,int progress); + /*** + * 广告关闭按钮点击 如果有(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdCloseButtonClicked(string placementId, ATCallbackInfo callbackInfo); + + + void startLoadingADSource(string placementId, ATCallbackInfo callbackInfo); + + + void finishLoadingADSource(string placementId, ATCallbackInfo callbackInfo); + + + void failToLoadADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message); + + void startBiddingADSource(string placementId, ATCallbackInfo callbackInfo); + + void finishBiddingADSource(string placementId, ATCallbackInfo callbackInfo); + + void failBiddingADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message); + + + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAdListener.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAdListener.cs.meta new file mode 100644 index 0000000..fce6b44 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAdListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4af6ae003832148048195c2a7e804588 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAdView.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAdView.cs new file mode 100644 index 0000000..1cbd001 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAdView.cs @@ -0,0 +1,112 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System.Text; + +namespace AnyThinkAds.Api +{ + public class ATNativeAdView + { + public ATNativeConfig config; + public ATNativeAdView(ATNativeConfig config) + { + this.config = config; + } + + + private string parentKey = "parent"; + private string appIconKey = "appIcon"; + private string mainImageKey = "mainImage"; + private string titleKey = "title"; + private string descKey = "desc"; + private string adLogoKey = "adLogo"; + private string ctaButtonKey = "cta"; + private string dislikeButtonKey = "dislike"; + private string elementsKey = "elements"; + + public string toJSON() + { + StringBuilder builder = new StringBuilder(); + builder.Append("{"); + if(config.parentProperty != null) + { + builder.Append("\"").Append(parentKey).Append("\""); + builder.Append(":"); + builder.Append(JsonUtility.ToJson(config.parentProperty)); + builder.Append(","); + } + if(config.appIconProperty != null){ + builder.Append("\"").Append(appIconKey).Append("\""); + builder.Append(":"); + builder.Append(JsonUtility.ToJson(config.appIconProperty)); + builder.Append(","); + } + + if(config.mainImageProperty != null) + { + builder.Append("\"").Append(mainImageKey).Append("\""); + builder.Append(":"); + builder.Append(JsonUtility.ToJson(config.mainImageProperty)); + builder.Append(","); + } + + if(config.titleProperty != null) + { + builder.Append("\"").Append(titleKey).Append("\""); + builder.Append(":"); + builder.Append(JsonUtility.ToJson(config.titleProperty)); + builder.Append(","); + } + if(config.descProperty != null) + { + builder.Append("\"").Append(descKey).Append("\""); + builder.Append(":"); + builder.Append(JsonUtility.ToJson(config.descProperty)); + builder.Append(","); + } + + if(config.adLogoProperty != null) + { + builder.Append("\"").Append(adLogoKey).Append("\""); + builder.Append(":"); + builder.Append(JsonUtility.ToJson(config.adLogoProperty)); + builder.Append(","); + } + + if(config.ctaButtonProperty != null) + { + builder.Append("\"").Append(ctaButtonKey).Append("\""); + builder.Append(":"); + builder.Append(JsonUtility.ToJson(config.ctaButtonProperty)); + builder.Append(","); + } + + if(config.dislikeButtonProperty != null) + { + builder.Append("\"").Append(dislikeButtonKey).Append("\""); + builder.Append(":"); + builder.Append(JsonUtility.ToJson(config.dislikeButtonProperty)); + builder.Append(","); + } + + if (config.elementsProperty != null) + { + builder.Append("\"").Append(elementsKey).Append("\""); + builder.Append(":"); + builder.Append(JsonUtility.ToJson(config.elementsProperty)); + } + + string temp = builder.ToString(); + + if (temp.EndsWith(",")) + { + temp = temp.Substring(0, temp.Length - 1); + } + + temp = temp + "}"; + + return temp; + + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAdView.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAdView.cs.meta new file mode 100644 index 0000000..b4790cb --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeAdView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c5dfbc036b5454843865c420afe58802 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeBannerAd.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeBannerAd.cs new file mode 100644 index 0000000..1ab46d9 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeBannerAd.cs @@ -0,0 +1,73 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System.Reflection; +using System; + +using AnyThinkAds.Common; +using AnyThinkAds.ThirdParty.LitJson; + + +namespace AnyThinkAds.Api +{ + public class ATNativeBannerAdShowingExtra + { + public static readonly string kATNativeBannerAdShowingExtraBackgroundColor = "background_color"; + public static readonly string kATNativeBannerAdShowingExtraAutorefreshInterval = "autorefresh_interval"; + public static readonly string kATNativeBannerAdShowingExtraHideCloseButtonFlag = "hide_close_button_flag"; + public static readonly string kATNativeBannerAdShowingExtraCTAButtonBackgroundColor = "cta_button_background_color"; + public static readonly string kATNativeBannerAdShowingExtraCTATextColor = "cta_button_title_color";//of type string, example:#3e2f10 + public static readonly string kATNativeBannerAdShowingExtraCTATextFont = "cta_text_font";//of type double + public static readonly string kATNativeBannerAdShowingExtraTitleColor = "title_color"; + public static readonly string kATNativeBannerAdShowingExtraTitleFont = "title_font"; + public static readonly string kATNativeBannerAdShowingExtraTextColor = "text_color"; + public static readonly string kATNativeBannerAdShowingExtraTextFont = "text_font"; + public static readonly string kATNativeBannerAdShowingExtraAdvertiserTextFont = "sponsor_text_font"; + public static readonly string kATNativeBannerAdShowingExtraAdvertiserTextColor = "spnosor_text_color"; + } + + public class ATNativeBannerAd + { + private static readonly ATNativeBannerAd instance = new ATNativeBannerAd(); + public IATNativeBannerAdClient client; + public ATNativeBannerAd() { + client = GetATNativeBannerAdClient(); + } + + public static ATNativeBannerAd Instance { + get { + return instance; + } + } + + public void loadAd(string placementId, Dictionary pairs) { + Debug.Log("ATNativeBannerAd::loadAd(" + placementId + ")"); + client.loadAd(placementId, JsonMapper.ToJson(pairs)); + } + + public bool adReady(string placementId) { + Debug.Log("ATNativeBannerAd::adReady(" + placementId + ")"); + return client.adReady(placementId); + } + + public void setListener(ATNativeBannerAdListener listener) { + Debug.Log("ATNativeBannerAd::setListener"); + client.setListener(listener); + } + + public void showAd(string placementId, ATRect rect, Dictionary pairs) { + Debug.Log("ATNativeBannerAd::showAd"); + client.showAd(placementId, rect, pairs); + } + + public void removeAd(string placementId) { + Debug.Log("ATNativeBannerAd::removeAd"); + client.removeAd(placementId); + } + + public IATNativeBannerAdClient GetATNativeBannerAdClient() + { + return AnyThinkAds.ATAdsClientFactory.BuildNativeBannerAdClient(); + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeBannerAd.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeBannerAd.cs.meta new file mode 100644 index 0000000..837fa18 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeBannerAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8425d877df61b4bdd9a237203df1cd6a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeBannerAdListener.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeBannerAdListener.cs new file mode 100644 index 0000000..a2fcadb --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeBannerAdListener.cs @@ -0,0 +1,38 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace AnyThinkAds.Api +{ + public interface ATNativeBannerAdListener + { + /*** + * 广告请求成功(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdLoaded(string placementId); + /*** + * 广告请求失败(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdLoadFail(string placementId, string code, string message); + /*** + * 广告展示(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdImpressed(string placementId, ATCallbackInfo callbackInfo); + /** + * 广告点击(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdClicked(string placementId, ATCallbackInfo callbackInfo); + /** + * 广告自动刷新(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdAutoRefresh(string placementId, ATCallbackInfo callbackInfo); + /** + * 广告自动刷新失败(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdAutoRefreshFailure(string placementId, string code, string message); + /** + * 关闭按钮被点击(内部逻辑不会移除ad view)(注意:对于Android来说,所有回调方法均不在Unity的主线程) + */ + void onAdCloseButtonClicked(string placementId); + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeBannerAdListener.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeBannerAdListener.cs.meta new file mode 100644 index 0000000..4025a5c --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeBannerAdListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e6318609c7806472dabe4189668a6c0b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeConfig.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeConfig.cs new file mode 100644 index 0000000..3b30725 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeConfig.cs @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace AnyThinkAds.Api +{ + public class ATNativeConfig + { + public ATNativeItemProperty parentProperty; + public ATNativeItemProperty appIconProperty; + public ATNativeItemProperty mainImageProperty; + public ATNativeItemProperty titleProperty; + public ATNativeItemProperty descProperty; + public ATNativeItemProperty adLogoProperty; + public ATNativeItemProperty ctaButtonProperty; + public ATNativeItemProperty dislikeButtonProperty; + public ATNativeItemProperty elementsProperty; + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeConfig.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeConfig.cs.meta new file mode 100644 index 0000000..bab286c --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeConfig.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d7bd4d96b427b425abe6e9acef00fe0f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeItemProperty.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeItemProperty.cs new file mode 100644 index 0000000..1987121 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeItemProperty.cs @@ -0,0 +1,59 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace AnyThinkAds.Api{ + public class ATNativeItemProperty { + public int x; + public int y; + public int width; + public int height; + public bool usesPixel; + + public string backgroundColor; + public string textColor; //只是针对text的view有效 + public int textSize; //只是针对text的view有效 + public bool isCustomClick; //只针对Android + + public ATNativeItemProperty(int x, int y, int width, int height, string backgroundColor, string textColor, int textSize, bool usesPixel, bool isCustomClick) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + this.usesPixel = usesPixel; + this.backgroundColor = backgroundColor; + this.textColor = textColor; + this.textSize = textSize; + this.isCustomClick = isCustomClick; + } + + + public ATNativeItemProperty(int x, int y, int width, int height, string backgroundColor, string textColor, int textSize, bool usesPixel) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + this.usesPixel = usesPixel; + this.backgroundColor = backgroundColor; + this.textColor = textColor; + this.textSize = textSize; + } + + public ATNativeItemProperty(int x,int y,int width,int height,string backgroundColor,string textColor,int textSize){ + this.x = x; + this.y = y; + this.width = width; + this.height = height; + this.backgroundColor = backgroundColor; + this.textColor = textColor; + this.textSize = textSize; + #if UNITY_ANDROID + this.usesPixel = true; + #else + this.usesPixel = false; + #endif + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeItemProperty.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeItemProperty.cs.meta new file mode 100644 index 0000000..68766f9 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATNativeItemProperty.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e57124f06079543f982965959cdfe0d3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRect.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRect.cs new file mode 100644 index 0000000..10ed73e --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRect.cs @@ -0,0 +1,62 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace AnyThinkAds.Api +{ + public class ATRect + { + public ATRect(int x, int y, int width, int height, bool usesPixel) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + this.usesPixel = usesPixel; + } + + public ATRect(int x, int y, int width, int height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + + public int x = 0; + public int y = 0; + public int width = 0; + public int height = 0; + // public bool usesPixel = false; + #if UNITY_ANDROID + public bool usesPixel = true; + #else + public bool usesPixel = false; + #endif + } + + public class ATSize + { + public ATSize(int width, int height, bool usesPixel) + { + this.width = width; + this.height = height; + this.usesPixel = usesPixel; + } + + public ATSize(int width, int height) + { + this.width = width; + this.height = height; + } + + public int width = 0; + public int height = 0; + + #if UNITY_ANDROID + public bool usesPixel = true; + #else + public bool usesPixel = false; + #endif + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRect.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRect.cs.meta new file mode 100644 index 0000000..0dbf7b0 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRect.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2779600e6766c4201864a4c3d8465746 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedAutoVideo.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedAutoVideo.cs new file mode 100644 index 0000000..087fb50 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedAutoVideo.cs @@ -0,0 +1,93 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System.Reflection; +using System; + +using AnyThinkAds.Common; +using AnyThinkAds.ThirdParty.LitJson; + + +namespace AnyThinkAds.Api +{ + public class ATRewardedAutoVideo + { + private static readonly ATRewardedAutoVideo instance = new ATRewardedAutoVideo(); + public IATRewardedVideoAdClient client; + + private ATRewardedAutoVideo() + { + client = GetATRewardedClient(); + } + + public static ATRewardedAutoVideo Instance + { + get + { + return instance; + } + } + + // Auto + public void addAutoLoadAdPlacementID(string[] placementIDList) + { + client.addAutoLoadAdPlacementID(placementIDList); + } + + public void removeAutoLoadAdPlacementID(string[] placementIDList) + { + if (placementIDList != null && placementIDList.Length > 0) + { + string placementIDListString = JsonMapper.ToJson(placementIDList); + client.removeAutoLoadAdPlacementID(placementIDListString); + Debug.Log("removeAutoLoadAdPlacementID, placementIDList === " + placementIDListString); + } + else + { + Debug.Log("removeAutoLoadAdPlacementID, placementIDList = null"); + } + } + + public bool autoLoadRewardedVideoReadyForPlacementID(string placementId) + { + return client.autoLoadRewardedVideoReadyForPlacementID(placementId); + } + public string getAutoValidAdCaches(string placementId) + { + return client.getAutoValidAdCaches(placementId); + } + + public string checkAutoAdStatus(string placementId) + { + return client.checkAutoAdStatus(placementId); + } + + + public void setAutoLocalExtra(string placementId, Dictionary pairs) + { + client.setAutoLocalExtra(placementId, JsonMapper.ToJson(pairs)); + } + public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID) + { + client.entryAutoAdScenarioWithPlacementID(placementId, scenarioID); + } + + public void showAutoAd(string placementId) + { + client.showAutoAd(placementId, JsonMapper.ToJson(new Dictionary())); + } + + public void showAutoAd(string placementId, Dictionary pairs) + { + client.showAutoAd(placementId, JsonMapper.ToJson(pairs)); + } + + public IATRewardedVideoAdClient GetATRewardedClient() + { + return AnyThinkAds.ATAdsClientFactory.BuildRewardedVideoAdClient(); + } + + + + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedAutoVideo.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedAutoVideo.cs.meta new file mode 100644 index 0000000..e8b26e4 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedAutoVideo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9b7859a96f8dd46f18bcc62fc76a371b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedVideo.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedVideo.cs new file mode 100644 index 0000000..c02ceee --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedVideo.cs @@ -0,0 +1,79 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System.Reflection; +using System; + +using AnyThinkAds.Common; +using AnyThinkAds.ThirdParty.LitJson; + + +namespace AnyThinkAds.Api +{ + public class ATRewardedVideo + { + private static readonly ATRewardedVideo instance = new ATRewardedVideo(); + public IATRewardedVideoAdClient client; + + private ATRewardedVideo() + { + client = GetATRewardedClient(); + } + + public static ATRewardedVideo Instance + { + get + { + return instance; + } + } + + + /*** + * + */ + public void loadVideoAd(string placementId, Dictionary pairs) + { + client.loadVideoAd(placementId, JsonMapper.ToJson(pairs)); + } + + + public bool hasAdReady(string placementId) + { + return client.hasAdReady(placementId); + } + + public void entryScenarioWithPlacementID(string placementId, string scenarioID) + { + client.entryScenarioWithPlacementID(placementId,scenarioID); + } + + public string checkAdStatus(string placementId) + { + return client.checkAdStatus(placementId); + } + + public string getValidAdCaches(string placementId) + { + return client.getValidAdCaches(placementId); + } + + public void showAd(string placementId) + { + client.showAd(placementId, JsonMapper.ToJson(new Dictionary())); + } + + public void showAd(string placementId, Dictionary pairs) + { + client.showAd(placementId, JsonMapper.ToJson(pairs)); + } + + public IATRewardedVideoAdClient GetATRewardedClient() + { + return AnyThinkAds.ATAdsClientFactory.BuildRewardedVideoAdClient(); + } + + + + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedVideo.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedVideo.cs.meta new file mode 100644 index 0000000..647d19e --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedVideo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 464138f9e35214456adacd5ef4f103ff +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedVideoListener.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedVideoListener.cs new file mode 100644 index 0000000..acf838d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedVideoListener.cs @@ -0,0 +1,90 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace AnyThinkAds.Api +{ + public interface ATRewardedVideoListener + { + /*** + * The Ad load successfully (note: for Android, all callback methods are not in the main thread of Unity) + */ + void onRewardedVideoAdLoaded(string placementId); + /*** + * The Ad load fail (note: for Android, all callback methods are not in the main thread of Unity) + */ + void onRewardedVideoAdLoadFail(string placementId,string code, string message); + /*** + * The Ad play (note: for Android, all callback methods are not in the main thread of Unity) + */ + void onRewardedVideoAdPlayStart(string placementId, ATCallbackInfo callbackInfo); + /*** + * The Ad play end (note: for Android, all callback methods are not in the main thread of Unity) + */ + void onRewardedVideoAdPlayEnd(string placementId, ATCallbackInfo callbackInfo); + /*** + * The Ad play fail(note: for Android, all callback methods are not in the main thread of Unity) + * @param code error code + * @param message error message + */ + void onRewardedVideoAdPlayFail(string placementId,string code, string message); + /** + * The Ad close(note: for Android, all callback methods are not in the main thread of Unity) + * @param isReward + */ + void onRewardedVideoAdPlayClosed(string placementId,bool isReward, ATCallbackInfo callbackInfo); + /*** + * The Ad click(note: for Android, all callback methods are not in the main thread of Unity) + */ + void onRewardedVideoAdPlayClicked(string placementId, ATCallbackInfo callbackInfo); + /** + * The Ad reward(note: for Android, all callback methods are not in the main thread of Unity) + */ + void onReward(string placementId, ATCallbackInfo callbackInfo); + + + void startLoadingADSource(string placementId, ATCallbackInfo callbackInfo); + + void finishLoadingADSource(string placementId, ATCallbackInfo callbackInfo); + + void failToLoadADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message); + + void startBiddingADSource(string placementId, ATCallbackInfo callbackInfo); + + void finishBiddingADSource(string placementId, ATCallbackInfo callbackInfo); + + void failBiddingADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message); + + + + + + + + } + + public interface ATRewardedVideoExListener : ATRewardedVideoListener { + /*** + * The Ad play again (note: for Android, all callback methods are not in the main thread of Unity) + */ + void onRewardedVideoAdAgainPlayStart(string placementId, ATCallbackInfo callbackInfo); + /*** + * The Ad play end again(note: for Android, all callback methods are not in the main thread of Unity) + */ + void onRewardedVideoAdAgainPlayEnd(string placementId, ATCallbackInfo callbackInfo); + /*** + * The Ad play fail again(note: for Android, all callback methods are not in the main thread of Unity) + */ + void onRewardedVideoAdAgainPlayFail(string placementId, string code, string message); + + /*** + * The Ad click again(note: for Android, all callback methods are not in the main thread of Unity) + */ + void onRewardedVideoAdAgainPlayClicked(string placementId, ATCallbackInfo callbackInfo); + /** + * The Ad reward again(note: for Android, all callback methods are not in the main thread of Unity) + */ + void onAgainReward(string placementId, ATCallbackInfo callbackInfo); + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedVideoListener.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedVideoListener.cs.meta new file mode 100644 index 0000000..1a7224a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATRewardedVideoListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9f798faca56bf4d4e9a8aa14eb694b96 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSDKAPI.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSDKAPI.cs new file mode 100644 index 0000000..93f60ef --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSDKAPI.cs @@ -0,0 +1,234 @@ +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System; +using UnityEngine; + + + +using AnyThinkAds.Common; +using AnyThinkAds.ThirdParty.LitJson; + + +namespace AnyThinkAds.Api +{ + public interface ATGetUserLocationListener + { + void didGetUserLocation(int location); + } + + public interface ATConsentDismissListener + { + void onConsentDismiss(); + } + + + public interface ATGetAreaListener + { + void onArea(string area); + void onError(string message); + } + + public class ATSDKAPI + { + public static readonly int kATUserLocationUnknown = 0; + public static readonly int kATUserLocationInEU = 1; + public static readonly int kATUserLocationOutOfEU = 2; + + public static readonly int PERSONALIZED = 0; + public static readonly int NONPERSONALIZED = 1; + public static readonly int UNKNOWN = 2; + + public static readonly int AREA_GLOBAL = 0; + public static readonly int AREA_CHINESE_MAINLAND = 1; + + + //for android and ios + public static readonly string OS_VERSION_NAME = "os_vn"; + public static readonly string OS_VERSION_CODE = "os_vc"; + public static readonly string APP_PACKAGE_NAME = "package_name"; + public static readonly string APP_VERSION_NAME = "app_vn"; + public static readonly string APP_VERSION_CODE = "app_vc"; + + public static readonly string BRAND = "brand"; + public static readonly string MODEL = "model"; + public static readonly string DEVICE_SCREEN_SIZE = "screen"; + public static readonly string MNC = "mnc"; + public static readonly string MCC = "mcc"; + + public static readonly string LANGUAGE = "language"; + public static readonly string TIMEZONE = "timezone"; + public static readonly string USER_AGENT = "ua"; + public static readonly string ORIENTATION = "orient"; + public static readonly string NETWORK_TYPE = "network_type"; + + //for android + public static readonly string INSTALLER = "it_src"; + public static readonly string ANDROID_ID = "android_id"; + public static readonly string GAID = "gaid"; + public static readonly string MAC = "mac"; + public static readonly string IMEI = "imei"; + public static readonly string OAID = "oaid"; + + //for ios + public static readonly string IDFA = "idfa"; + public static readonly string IDFV = "idfv"; + + + + private static readonly IATSDKAPIClient client = GetATSDKAPIClient(); + + public static void initSDK(string appId, string appKey) + { + client.initSDK(appId, appKey); + } + + public static void initSDK(string appId, string appKey, ATSDKInitListener listener) + { + client.initSDK(appId, appKey, listener); + } + + public static void showDebuggerUI() + { + client.showDebuggerUI(); + } + + public static void showDebuggerUI(string debugKey) + { + client.showDebuggerUI(debugKey); + } + + public static void setGDPRLevel(int level) + { + client.setGDPRLevel(level); + } + + public static void getUserLocation(ATGetUserLocationListener listener) + { + client.getUserLocation(listener); + } + + public static int getGDPRLevel() { + return client.getGDPRLevel(); + } + + public static bool isEUTraffic() { + return client.isEUTraffic(); + } + + public static void setChannel(string channel) + { + client.setChannel(channel); + } + + public static void setSubChannel(string subChannel) + { + client.setSubChannel(subChannel); + } + + public static void initCustomMap(Dictionary customMap) + { + client.initCustomMap(JsonMapper.ToJson(customMap)); + } + + public static void setCustomDataForPlacementID(Dictionary customData, string placementID) + { + client.setCustomDataForPlacementID(JsonMapper.ToJson(customData), placementID); + } + + public static void showGDPRAuth() + { + client.showGDPRAuth(); + } + + public static void showGDPRConsentDialog(ATConsentDismissListener listener) + { + client.showGDPRConsentDialog(listener); + } + + public static void setLogDebug(bool isDebug) + { + client.setLogDebug(isDebug); + ATLogger.IsDebug = isDebug; + } + + public static void addNetworkGDPRInfo(int networkType, Dictionary dictionary) + { + client.addNetworkGDPRInfo(networkType, JsonMapper.ToJson(dictionary)); + } + + public static void deniedUploadDeviceInfo(string[] deniedInfo) + { + if (deniedInfo != null && deniedInfo.Length > 0) + { + string deniedString = JsonMapper.ToJson(deniedInfo); + client.deniedUploadDeviceInfo(deniedString); + Debug.Log("deniedUploadDeviceInfo, deniedInfo === " + deniedString); + } + else + { + Debug.Log("deniedUploadDeviceInfo, deniedInfo = null"); + } + + } + + private static IATSDKAPIClient GetATSDKAPIClient(){ + Debug.Log("GetATSDKAPIClient"); + return AnyThinkAds.ATAdsClientFactory.BuildSDKAPIClient(); + } + + public static void setExcludeBundleIdArray(string[] bundleIds) + { + if (bundleIds != null && bundleIds.Length > 0) + { + string bundleIdsString = JsonMapper.ToJson(bundleIds); + Debug.Log("setExcludeBundleIdArray, bundleIdsString === " + bundleIdsString); + + client.setExcludeBundleIdArray(bundleIdsString); + } + else + { + Debug.Log("setExcludeBundleIdArray, bundleIdsString = null"); + } + + } + + public static void setExcludeAdSourceIdArrayForPlacementID(string placementID, string[] adSourceIds) + { + if (adSourceIds != null && adSourceIds.Length > 0) + { + string adSourceIdsString = JsonMapper.ToJson(adSourceIds); + Debug.Log("setExcludeAdSourceIdArrayForPlacementID, adSourceIdsString === " + adSourceIdsString); + + client.setExcludeAdSourceIdArrayForPlacementID(placementID, adSourceIdsString); + } + else + { + Debug.Log("setExcludeAdSourceIdArrayForPlacementID, adSourceIdsString = null"); + } + + } + + public static void setSDKArea(int area) + { + client.setSDKArea(area); + } + + public static void getArea(ATGetAreaListener listener) + { + client.getArea(listener); + } + + public static void setWXStatus(bool install) + { + client.setWXStatus(install); + } + + public static void setLocation(double longitude, double latitude) + { + client.setLocation(longitude, latitude); + } + + } +} + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSDKAPI.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSDKAPI.cs.meta new file mode 100644 index 0000000..8600fbc --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSDKAPI.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 19984fc5417044ecfa86ae3b181eb6f7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSDKInitListener.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSDKInitListener.cs new file mode 100644 index 0000000..20bafd8 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSDKInitListener.cs @@ -0,0 +1,13 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace AnyThinkAds.Api +{ + public interface ATSDKInitListener + { + + void initSuccess(); + void initFail(string message); + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSDKInitListener.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSDKInitListener.cs.meta new file mode 100644 index 0000000..92fc9d1 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSDKInitListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 083fcd51a2324455fb259c1ec03c91c4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSplashAd.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSplashAd.cs new file mode 100644 index 0000000..cc78f87 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSplashAd.cs @@ -0,0 +1,73 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System.Reflection; +using System; + +using AnyThinkAds.Common; +using AnyThinkAds.ThirdParty.LitJson; + +namespace AnyThinkAds.Api +{ + public class ATSplashAdLocalExtra + { + //Only for GDT (true: open download dialog, false: download directly) + public static readonly string kATSplashAdClickConfirmStatus = "ad_click_confirm_status"; + } + public class ATSplashAd + { + private static readonly ATSplashAd instance = new ATSplashAd(); + public IATSplashAdClient client; + + private ATSplashAd() + { + client = AnyThinkAds.ATAdsClientFactory.BuildSplashAdClient(); + } + + public static ATSplashAd Instance + { + get + { + return instance; + } + } + + public void loadSplashAd(string placementId, Dictionary pairs, int fetchAdTimeout = 5000, string defaultAdSourceConfig = "") + { + #if UNITY_ANDROID + client.loadSplashAd(placementId, fetchAdTimeout, defaultAdSourceConfig, JsonMapper.ToJson(pairs)); + #elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE + //TODO iOS的开屏加载 + pairs.Add("tolerate_timeout", fetchAdTimeout); + pairs.Add("default_adSource_config", defaultAdSourceConfig); + + client.loadSplashAd(placementId, fetchAdTimeout, defaultAdSourceConfig, JsonMapper.ToJson(pairs)); + #endif + } + + public void showSplashAd(string placementId, Dictionary pairs) + { + client.showSplashAd(placementId, JsonMapper.ToJson(pairs)); + } + + public bool hasSplashAdReady(string placementId) + { + return client.hasSplashAdReady(placementId); + } + + public string checkAdStatus(string placementId) + { + return client.checkAdStatus(placementId); + } + + public string getValidAdCaches(string placementId) + { + return client.getValidAdCaches(placementId); + } + + public void entryScenarioWithPlacementID(string placementId, string scenarioID) + { + client.entryScenarioWithPlacementID(placementId, scenarioID); + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSplashAd.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSplashAd.cs.meta new file mode 100644 index 0000000..d34122f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSplashAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0d9c30e7d78e94fa5b00d69206cf5e6d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSplashAdListener.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSplashAdListener.cs new file mode 100644 index 0000000..8a8bab5 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSplashAdListener.cs @@ -0,0 +1,40 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +///summary +///(注意:对于Android来说,所有回调方法均不在Unity的主线程) +///sumary +namespace AnyThinkAds.Api +{ + public interface ATSplashAdListener + { + void onSplashAdLoad(string unitId, bool isTimeout); + + void onSplashAdLoadTimeOut(string unitId); + + void onSplashAdLoadFailed(string unitId, string code, string msg); + + void onSplashAdShow(string unitId, ATCallbackInfo callbackInfo); + + void onSplashAdClick(string unitId, ATCallbackInfo callbackInfo); + + void onSplashAdDismiss(string unitId, ATCallbackInfo callbackInfo); + + void onSplashAdDeeplinkCallback(string unitId, ATCallbackInfo callbackInfo, bool isSuccess); + + void onSplashAdDownloadConfirm(string unitId, ATCallbackInfo callbackInfo); + + void startLoadingADSource(string placementId, ATCallbackInfo callbackInfo); + + + void finishLoadingADSource(string placementId, ATCallbackInfo callbackInfo); + + void failToLoadADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message); + + void startBiddingADSource(string placementId, ATCallbackInfo callbackInfo); + + void finishBiddingADSource(string placementId, ATCallbackInfo callbackInfo); + + void failBiddingADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message); + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSplashAdListener.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSplashAdListener.cs.meta new file mode 100644 index 0000000..97f4a7b --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Api/ATSplashAdListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1b57c158761e14a938991e5eee8042b2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Bridge.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Bridge.meta new file mode 100644 index 0000000..aecb526 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Bridge.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b4096c701283c46fa994f76d51e947a0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Bridge/thinkup_bridge.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Bridge/thinkup_bridge.aar new file mode 100644 index 0000000..82da75d Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Bridge/thinkup_bridge.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Bridge/thinkup_bridge.aar.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Bridge/thinkup_bridge.aar.meta new file mode 100644 index 0000000..7b769e5 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Bridge/thinkup_bridge.aar.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: b2cf80647e05e47b284324f0d41fcdae +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common.meta new file mode 100644 index 0000000..85aa442 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1f5acd92290394659966a736c0edae24 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/ATLogger.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/ATLogger.cs new file mode 100644 index 0000000..39cfdad --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/ATLogger.cs @@ -0,0 +1,95 @@ +using System; +using UnityEngine; + +namespace AnyThinkAds.Common +{ + public class ATLogger + { + private static bool isDebug = false; + public static bool IsDebug + { + get { + return isDebug; + } + set { + isDebug = value; + } + } + + // public static void Log(string msg) + // { + // Log(msg, null); + // } + + // public static void Log(string format, object obj) + // { + // Log(format, obj, null); + // } + + public static void Log(string format, object obj1 = null, object obj2 = null) + { + if (!isDebug) { + return; + } + try { + if (obj1 == null && obj2 == null) + { + Debug.Log(format); + } + else if (obj1 != null && obj2 == null) + { + Debug.Log(String.Format(format, obj1)); + } + else if (obj1 == null && obj2 != null) + { + Debug.Log(String.Format(format, obj2)); + } + else { + Debug.Log(String.Format(format, obj1, obj2)); + } + } catch(Exception e) + { + Debug.LogError("Log error: " + e.Message); + } + } + + + // public static void LogError(string msg) + // { + // LogError(msg, null); + // } + + // public static void LogError(string format, object obj) + // { + // LogError(format, obj, null); + // } + + public static void LogError(string format, object obj1 = null, object obj2 = null) + { + if (!isDebug) { + return; + } + try { + if (obj1 == null && obj2 == null) + { + Debug.LogError(format); + } + else if (obj1 != null && obj2 == null) + { + Debug.LogError(String.Format(format, obj1)); + } + else if (obj1 == null && obj2 != null) + { + Debug.LogError(String.Format(format, obj2)); + } + else { + Debug.LogError(String.Format(format, obj1, obj2)); + } + } catch(Exception e) + { + Debug.LogError("Log error: " + e.Message); + } + } + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/ATLogger.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/ATLogger.cs.meta new file mode 100644 index 0000000..3e1a1c7 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/ATLogger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 45d2ba570cbd740db8eaf1d145007f77 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATBannerAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATBannerAdClient.cs new file mode 100644 index 0000000..d6e21c1 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATBannerAdClient.cs @@ -0,0 +1,75 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using AnyThinkAds.Api; + +namespace AnyThinkAds.Common +{ + public interface IATBannerAdClient : IATBannerEvents + { + /*** + * 请求广告 + * @param placementId 广告位id + * @parm mapJson 各平台的私有属性 一般可以不调用 + */ + void loadBannerAd(string placementId, string mapJson); + /** + * 获取广告状态信息(是否正在加载、是否存在可以展示广告、广告缓存详细信息) + * @param unityid + * + */ + string checkAdStatus(string placementId); + /*** + * + * 设置监听回调接口 + * + * @param listener + */ + void setListener(ATBannerAdListener listener); + /*** + * + * 展示广告, + * @param placementId + * @param pass bottom or top for position + * @parm mapJson + */ + void showBannerAd(string placementId, string position, string mapJson); + /*** + * + * 展示广告, + * @param placementId + * @param rect the region used to show banner ad; currently only x&y fields in rect are used(as the origin, or top left corner of the banner). + * @parm mapJson + */ + void showBannerAd(string placementId, ATRect rect, string mapJson); + /*** + * + * 清理广告 + * @param placementId + * @param anyThinkNativeAdView 这里的属性是显示区域坐标等配置,需要自行设置 + */ + void cleanBannerAd(string placementId); + /*** + * + * 隐藏广告 + * @param placementId + * @param rect the region used to show banner ad. + */ + void hideBannerAd(string placementId); + /*** + * + * (重新)展示之前隐藏的广告 + * @param placementId + */ + void showBannerAd(string placementId); + /*** + * 清理缓存 + */ + void cleanCache(string placementId); + + /*** + * 获取所有可用缓存广告 + */ + string getValidAdCaches(string placementId); + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATBannerAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATBannerAdClient.cs.meta new file mode 100644 index 0000000..ea12be0 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATBannerAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d36adfb982bfc463f9ffb4b30ceede5c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATDownloadClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATDownloadClient.cs new file mode 100644 index 0000000..b9b0429 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATDownloadClient.cs @@ -0,0 +1,14 @@ + +using AnyThinkAds.Api; + +namespace AnyThinkAds.Common +{ + public interface IATDownloadClient + { + + /** + * @param listener + */ + void setListener(ATDownloadAdListener listener); + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATDownloadClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATDownloadClient.cs.meta new file mode 100644 index 0000000..58355dd --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATDownloadClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0615492f4518b488590a3688f063873e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATInterstitialAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATInterstitialAdClient.cs new file mode 100644 index 0000000..17d23de --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATInterstitialAdClient.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using AnyThinkAds.Api; + +namespace AnyThinkAds.Common +{ + public interface IATInterstitialAdClient : IATInterstitialAdEvents + { + /*** + * 请求广告 + * @param placementId 广告位id + * @parm mapJson 各平台的私有属性 一般可以不调用 + */ + void loadInterstitialAd(string placementId, string mapJson); + /*** + * + * 设置监听回调接口 + * + * @param listener + */ + void setListener(ATInterstitialAdListener listener); + /** + * 是否存在可以展示的广告 + * @param unityid + */ + bool hasInterstitialAdReady(string placementId); + /** + * 获取广告状态信息(是否正在加载、是否存在可以展示广告、广告缓存详细信息) + * @param unityid + * + */ + string checkAdStatus(string placementId); + /*** + * 显示广告 + */ + void showInterstitialAd(string placementId, string mapJson); + + + /*** + * 获取所有可用缓存广告 + */ + string getValidAdCaches(string placementId); + + void entryScenarioWithPlacementID(string placementId, string scenarioID); + + + string checkAutoAdStatus(string placementId); + + void addAutoLoadAdPlacementID(string[] placementIDList); + + void removeAutoLoadAdPlacementID(string placementId); + + bool autoLoadInterstitialAdReadyForPlacementID(string placementId); + + string getAutoValidAdCaches(string placementId); + + void setAutoLocalExtra(string placementId, string mapJson); + + void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID); + + void showAutoAd(string placementId, string mapJson); + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATInterstitialAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATInterstitialAdClient.cs.meta new file mode 100644 index 0000000..a3b8376 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATInterstitialAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 29aeb78d58bc140fa97ee8acc8403bd1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATNativeAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATNativeAdClient.cs new file mode 100644 index 0000000..1e0cb53 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATNativeAdClient.cs @@ -0,0 +1,73 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +using AnyThinkAds.Api; + +namespace AnyThinkAds.Common +{ + public interface IATNativeAdClient : IATNativeAdEvents + { + /*** + * 请求广告 + * @param placementId 广告位id + * @parm mapJson 各平台的私有属性 一般可以不调用 + */ + void loadNativeAd(string placementId, string mapJson); + /*** + * 判断是否有广告存在 + * 可以在显示广告之前调用 + * @param placementId 广告位id + */ + bool hasAdReady(string placementId); + /** + * 获取广告状态信息(是否正在加载、是否存在可以展示广告、广告缓存详细信息) + * @param unityid + * + */ + string checkAdStatus(string placementId); + /*** + * + * 设置监听回调接口 + * + * @param listener + */ + void setListener(ATNativeAdListener listener); + /*** + * + * 展示广告, + * @param placementId + * @param anyThinkNativeAdView 这里的属性是显示区域坐标等配置,需要自行设置 + * @parm mapJson + */ + void renderAdToScene(string placementId, ATNativeAdView anyThinkNativeAdView, string mapJson); + + /*** + * + * 清理广告 + * @param placementId + * @param anyThinkNativeAdView 这里的属性是显示区域坐标等配置,需要自行设置 + */ + void cleanAdView(string placementId, ATNativeAdView anyThinkNativeAdView); + /*** + * 页面显示 + */ + void onApplicationForces(string placementId, ATNativeAdView anyThinkNativeAdView); + /*** + * 页面隐藏 + */ + void onApplicationPasue(string placementId, ATNativeAdView anyThinkNativeAdView); + /*** + * 清理缓存 + */ + void cleanCache(string placementId); + + /*** + * 获取所有可用缓存广告 + */ + string getValidAdCaches(string placementId); + + void entryScenarioWithPlacementID(string placementId, string scenarioID); + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATNativeAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATNativeAdClient.cs.meta new file mode 100644 index 0000000..67ebe3b --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATNativeAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8e60de0648af644da95a888d0ddb83f6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATNativeBannerAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATNativeBannerAdClient.cs new file mode 100644 index 0000000..710f1a8 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATNativeBannerAdClient.cs @@ -0,0 +1,45 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +using AnyThinkAds.Api; + +namespace AnyThinkAds.Common +{ + public interface IATNativeBannerAdClient : IATNativeAdEvents + { + /*** + * 请求广告 + * @param placementId 广告位id + * @parm mapJson 各平台的私有属性 一般可以不调用 + */ + void loadAd(string placementId, string mapJson); + + /*** + * 判断是否有广告存在 + * 可以在显示广告之前调用 + * @param placementId 广告位id + */ + bool adReady(string placementId); + /*** + * + * 设置监听回调接口 + * + * @param listener + */ + void setListener(ATNativeBannerAdListener listener); + /*** + * + * 展示广告, + * @param placementId + * @param rect + */ + void showAd(string placementId, ATRect rect, Dictionary pairs); + /*** + * + * 移除广告 + * @param placementId + */ + void removeAd(string placementId); + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATNativeBannerAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATNativeBannerAdClient.cs.meta new file mode 100644 index 0000000..62a6440 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATNativeBannerAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d20c708125d9743b2af7163dfd4b54b7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATRewardedVideoAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATRewardedVideoAdClient.cs new file mode 100644 index 0000000..b209271 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATRewardedVideoAdClient.cs @@ -0,0 +1,63 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +using AnyThinkAds.Api; + +namespace AnyThinkAds.Common +{ + public interface IATRewardedVideoAdClient : IATRewardedVideoEvents + { + /** + * 请求视屏广告 + * @param placementId 广告位id + * @parm mapJson 平台私有参数 一般不些 + */ + void loadVideoAd(string placementId, string mapJson); + /** + * @param listener 监听回调 + */ + void setListener(ATRewardedVideoListener listener); + /** + * 是否存在可以展示的广告 + * @param unityid + * + */ + bool hasAdReady(string placementId); + /** + * 获取广告状态信息(是否正在加载、是否存在可以展示广告、广告缓存详细信息) + * @param unityid + * + */ + string checkAdStatus(string placementId); + /*** + * 显示广告 + */ + void showAd(string placementId, string mapJson); + + /*** + * 获取所有可用缓存广告 + */ + string getValidAdCaches(string placementId); + + void entryScenarioWithPlacementID(string placementId, string scenarioID); + + + string checkAutoAdStatus(string placementId); + + void addAutoLoadAdPlacementID(string[] placementIDList); + + void removeAutoLoadAdPlacementID(string placementId); + + bool autoLoadRewardedVideoReadyForPlacementID(string placementId); + + string getAutoValidAdCaches(string placementId); + + void setAutoLocalExtra(string placementId, string mapJson); + + void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID); + + void showAutoAd(string placementId, string mapJson); + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATRewardedVideoAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATRewardedVideoAdClient.cs.meta new file mode 100644 index 0000000..a6d29dd --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATRewardedVideoAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9dc52b7fdd47842a3aaae5c4b8fa95de +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATSDKAPIClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATSDKAPIClient.cs new file mode 100644 index 0000000..5783db0 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATSDKAPIClient.cs @@ -0,0 +1,35 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using AnyThinkAds.Api; + +namespace AnyThinkAds.Common +{ + public interface IATSDKAPIClient + { + void initSDK(string appId, string appKey); + void initSDK(string appId, string appKey, ATSDKInitListener listener); + void showDebuggerUI(); + void showDebuggerUI(string debugKey); + void getUserLocation(ATGetUserLocationListener listener); + void setGDPRLevel(int level); + void showGDPRAuth(); + void showGDPRConsentDialog(ATConsentDismissListener listener); + void addNetworkGDPRInfo(int networkType, string mapJson); + void setChannel(string channel); + void setSubChannel(string subchannel); + void initCustomMap(string cutomMap); + void setCustomDataForPlacementID(string customData, string placementID); + void setLogDebug(bool isDebug); + int getGDPRLevel(); + bool isEUTraffic(); + void deniedUploadDeviceInfo(string deniedInfo); + + void setExcludeBundleIdArray(string bundleIds); + void setExcludeAdSourceIdArrayForPlacementID(string placementID, string adsourceIds); + void setSDKArea(int area); + void getArea(ATGetAreaListener listener); + void setWXStatus(bool install); + void setLocation(double longitude, double latitude); + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATSDKAPIClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATSDKAPIClient.cs.meta new file mode 100644 index 0000000..745b7c9 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATSDKAPIClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fccdac04e450f4b6f8bf324cca2ad647 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATSplashAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATSplashAdClient.cs new file mode 100644 index 0000000..b791112 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATSplashAdClient.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using AnyThinkAds.Api; + +namespace AnyThinkAds.Common +{ + public interface IATSplashAdClient : IATSplashEvents + { + // void loadSplashAd(string placementId, string mapJson); + void loadSplashAd(string placementId, int fetchAdTimeout, string defaultAdSourceConfig, string mapJson); + void setListener(ATSplashAdListener listener); + + bool hasSplashAdReady(string placementId); + + string checkAdStatus(string placementId); + + void showSplashAd(string placementId, string mapJson); + + string getValidAdCaches(string placementId); + + void entryScenarioWithPlacementID(string placementId, string scenarioID); + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATSplashAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATSplashAdClient.cs.meta new file mode 100644 index 0000000..6c4e7df --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Common/IATSplashAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f2826cdfe64c14dcca1ffaf4e5a5cb7a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform.meta new file mode 100644 index 0000000..eb28a39 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8c5eb205b9d4a4032867f42f8345ae85 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/ATAdsClientFactory.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/ATAdsClientFactory.cs new file mode 100644 index 0000000..dfd4504 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/ATAdsClientFactory.cs @@ -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 onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdImpressEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onAdAutoRefreshEvent; + public event EventHandler onAdAutoRefreshFailureEvent; + public event EventHandler onAdCloseEvent; + public event EventHandler onAdCloseButtonTappedEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler 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 onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdShowEvent; + public event EventHandler onAdShowFailureEvent; + public event EventHandler onAdCloseEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onAdVideoStartEvent; + public event EventHandler onAdVideoFailureEvent; + public event EventHandler onAdVideoEndEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler 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 onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdImpressEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onAdVideoStartEvent; + public event EventHandler onAdVideoEndEvent; + public event EventHandler onAdVideoProgressEvent; + public event EventHandler onAdCloseEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler 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 onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdImpressEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onAdVideoStartEvent; + public event EventHandler onAdVideoEndEvent; + public event EventHandler onAdVideoProgressEvent; + public event EventHandler onAdCloseEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler 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 pairs){} + + public void removeAd(string unitId){} + } + + class UnityRewardedVideoAdClient : IATRewardedVideoAdClient + { + public event EventHandler onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdVideoStartEvent; + public event EventHandler onAdVideoEndEvent; + public event EventHandler onAdVideoFailureEvent; + public event EventHandler onAdVideoCloseEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onRewardEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler onAdSourceBiddingFailureEvent; + public event EventHandler onPlayAgainStart; + public event EventHandler onPlayAgainEnd; + public event EventHandler onPlayAgainFailure; + public event EventHandler onPlayAgainClick; + public event EventHandler 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 onAdLoadTimeoutEvent; + public event EventHandler onDeeplinkEvent; + public event EventHandler onDownloadConfirmEvent; + public event EventHandler onAdShowEvent; + public event EventHandler onAdCloseEvent; + // called if the ad has failed to be shown + public event EventHandler onAdShowFailureEvent; + public event EventHandler onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onRewardEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler onAdSourceBiddingFailureEvent; + public event EventHandler onPlayAgainStart; + public event EventHandler onPlayAgainEnd; + public event EventHandler onPlayAgainFailure; + public event EventHandler onPlayAgainClick; + public event EventHandler 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) {} + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/ATAdsClientFactory.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/ATAdsClientFactory.cs.meta new file mode 100644 index 0000000..2784583 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/ATAdsClientFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6c8a4f3522d7148ee9c8a9ead3279202 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android.meta new file mode 100644 index 0000000..0f1479d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: da19b2447f2434d0b83899d1751efc3a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATAreaListener.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATAreaListener.cs new file mode 100644 index 0000000..c6ae3e0 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATAreaListener.cs @@ -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); + } + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATAreaListener.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATAreaListener.cs.meta new file mode 100644 index 0000000..373d32d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATAreaListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 34e0bea6b21914047977e0bb6fc80d08 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATBannerAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATBannerAdClient.cs new file mode 100644 index 0000000..7382d65 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATBannerAdClient.cs @@ -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 bannerHelperMap = new Dictionary(); + + + private ATBannerAdListener anyThinkListener; + + public event EventHandler onAdLoadEvent; + + // triggers when a banner ad has failed to load + public event EventHandler onAdLoadFailureEvent; + + // triggers when a banner ad generates an impression + public event EventHandler onAdImpressEvent; + + // triggers when the user clicks a banner ad + public event EventHandler onAdClickEvent; + + // triggers when the ad refreshes + public event EventHandler onAdAutoRefreshEvent; + + // triggers when the ad fails to auto refresh + public event EventHandler onAdAutoRefreshFailureEvent; + + // triggers when the banner ad is closed + public event EventHandler onAdCloseEvent; + + // triggers when the users closes the ad via the button + public event EventHandler onAdCloseButtonTappedEvent; + + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler 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("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("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)); + } + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATBannerAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATBannerAdClient.cs.meta new file mode 100644 index 0000000..da349b8 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATBannerAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9c7bec7d500e74ca995affc2bd45de2c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATDownloadClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATDownloadClient.cs new file mode 100644 index 0000000..7176bfc --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATDownloadClient.cs @@ -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); + } + } + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATDownloadClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATDownloadClient.cs.meta new file mode 100644 index 0000000..7b3589d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATDownloadClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c15069ef3f95a4e899d4a8d36931a17c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATGDPRConsentDismissListener.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATGDPRConsentDismissListener.cs new file mode 100644 index 0000000..8d0d30b --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATGDPRConsentDismissListener.cs @@ -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(); + } + } + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATGDPRConsentDismissListener.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATGDPRConsentDismissListener.cs.meta new file mode 100644 index 0000000..6050c15 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATGDPRConsentDismissListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 01aabe528bcb74cac9ab3e883dbbcae6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATInterstitialAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATInterstitialAdClient.cs new file mode 100644 index 0000000..5e6e3a8 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATInterstitialAdClient.cs @@ -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 onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdShowEvent; + public event EventHandler onAdShowFailureEvent; + public event EventHandler onAdCloseEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onAdVideoStartEvent; + public event EventHandler onAdVideoFailureEvent; + public event EventHandler onAdVideoEndEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler onAdSourceBiddingFailureEvent; + + private Dictionary interstitialHelperMap = new Dictionary(); + + //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 ("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("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("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("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("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("checkAdStatus", placementId); + } + catch (System.Exception e) + { + System.Console.WriteLine("Exception caught: {0}", e); + Debug.Log("Unity: ATInterstitialAdClient:checkAutoAdStatus() : error." + e.Message); + } + + return adStatusJsonString; + } + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATInterstitialAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATInterstitialAdClient.cs.meta new file mode 100644 index 0000000..6dcb123 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATInterstitialAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2974fada499ca461fb812844f898b961 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATMsgTools.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATMsgTools.cs new file mode 100644 index 0000000..13d99ed --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATMsgTools.cs @@ -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 + + + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATMsgTools.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATMsgTools.cs.meta new file mode 100644 index 0000000..c40d2c1 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATMsgTools.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c7c6efa7c8667421bad3af1671dd777d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNativeAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNativeAdClient.cs new file mode 100644 index 0000000..193bedf --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNativeAdClient.cs @@ -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 onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdImpressEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onAdVideoStartEvent; + public event EventHandler onAdVideoEndEvent; + public event EventHandler onAdVideoProgressEvent; + public event EventHandler onAdCloseEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler onAdSourceBiddingFailureEvent; + + private Dictionary nativeAdHelperMap = new Dictionary(); + 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 ("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("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("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)); + } + + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNativeAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNativeAdClient.cs.meta new file mode 100644 index 0000000..a8b2108 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNativeAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 073dd039f9983464080e9cee9b8b81ab +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNativeBannerAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNativeBannerAdClient.cs new file mode 100644 index 0000000..885776b --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNativeBannerAdClient.cs @@ -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 onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdImpressEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onAdVideoStartEvent; + public event EventHandler onAdVideoEndEvent; + public event EventHandler onAdVideoProgressEvent; + public event EventHandler onAdCloseEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler 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 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)); + + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNativeBannerAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNativeBannerAdClient.cs.meta new file mode 100644 index 0000000..f1351f9 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNativeBannerAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bc1750da0babf40ce9f9986778b3def4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNetTrafficListener.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNetTrafficListener.cs new file mode 100644 index 0000000..6c6ee88 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNetTrafficListener.cs @@ -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); + } + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNetTrafficListener.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNetTrafficListener.cs.meta new file mode 100644 index 0000000..2c15ae9 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATNetTrafficListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8870deba0682c40ed9c907af5aab5b96 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATRewardedVideoAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATRewardedVideoAdClient.cs new file mode 100644 index 0000000..fc83cbd --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATRewardedVideoAdClient.cs @@ -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 onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdVideoStartEvent; + public event EventHandler onAdVideoEndEvent; + public event EventHandler onAdVideoFailureEvent; + public event EventHandler onAdVideoCloseEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onRewardEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler onAdSourceBiddingFailureEvent; + public event EventHandler onPlayAgainStart; + public event EventHandler onPlayAgainEnd; + public event EventHandler onPlayAgainFailure; + public event EventHandler onPlayAgainClick; + public event EventHandler onPlayAgainReward; + + + private Dictionary videoHelperMap = new Dictionary(); + + 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 ("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("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("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("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("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("checkAdStatus", placementId); + } + catch (System.Exception e) + { + System.Console.WriteLine("Exception caught: {0}", e); + Debug.Log("Unity: ATRewardedVideoAdClient:checkAutoAdStatus() : error." + e.Message); + } + + return adStatusJsonString; + } + + + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATRewardedVideoAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATRewardedVideoAdClient.cs.meta new file mode 100644 index 0000000..1b93450 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATRewardedVideoAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b67705314096943b09a0f14eafff6a62 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATSDKAPIClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATSDKAPIClient.cs new file mode 100644 index 0000000..2e0a511 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATSDKAPIClient.cs @@ -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("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("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); + } + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATSDKAPIClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATSDKAPIClient.cs.meta new file mode 100644 index 0000000..c26b89e --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATSDKAPIClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ff0227a36885e478ea01e4084ba344d7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATSplashAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATSplashAdClient.cs new file mode 100644 index 0000000..bd83083 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATSplashAdClient.cs @@ -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 onAdLoadTimeoutEvent; + public event EventHandler onDeeplinkEvent; + public event EventHandler onDownloadConfirmEvent; + public event EventHandler onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdShowEvent; + public event EventHandler onAdShowFailureEvent; + public event EventHandler onAdCloseEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler onAdSourceBiddingFailureEvent; + + private Dictionary splashHelperMap = new Dictionary(); + 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("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("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("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("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)); + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATSplashAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATSplashAdClient.cs.meta new file mode 100644 index 0000000..8bff32a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/Android/ATSplashAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a4263f047452042a1ae0319969384830 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS.meta new file mode 100644 index 0000000..88ffc49 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7b2e16073d63e4d5188cb6e223698c73 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATBannerAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATBannerAdClient.cs new file mode 100644 index 0000000..2ada3a2 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATBannerAdClient.cs @@ -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 onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdImpressEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onAdAutoRefreshEvent; + public event EventHandler onAdAutoRefreshFailureEvent; + public event EventHandler onAdCloseEvent; + public event EventHandler onAdCloseButtonTappedEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler 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)); + } + + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATBannerAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATBannerAdClient.cs.meta new file mode 100644 index 0000000..5a83991 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATBannerAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 954a7ddf44b474445bf858fc53ee63fe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATInterstitialAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATInterstitialAdClient.cs new file mode 100644 index 0000000..1e15d79 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATInterstitialAdClient.cs @@ -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 onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdShowEvent; + public event EventHandler onAdShowFailureEvent; + public event EventHandler onAdCloseEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onAdVideoStartEvent; + public event EventHandler onAdVideoFailureEvent; + public event EventHandler onAdVideoEndEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler 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); + } + + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATInterstitialAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATInterstitialAdClient.cs.meta new file mode 100644 index 0000000..3af1d34 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATInterstitialAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 950c39b6d4dc7469da41ca3af9d9bb5e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATNativeAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATNativeAdClient.cs new file mode 100644 index 0000000..435e94c --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATNativeAdClient.cs @@ -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 onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdImpressEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onAdVideoStartEvent; + public event EventHandler onAdVideoEndEvent; + public event EventHandler onAdVideoProgressEvent; + public event EventHandler onAdCloseEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler 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)); + + } + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATNativeAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATNativeAdClient.cs.meta new file mode 100644 index 0000000..55ea4d9 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATNativeAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: adbfdd1abf5ca4e94b94f108d645ed66 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATNativeBannerAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATNativeBannerAdClient.cs new file mode 100644 index 0000000..db1c297 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATNativeBannerAdClient.cs @@ -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 onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdImpressEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onAdVideoStartEvent; + public event EventHandler onAdVideoEndEvent; + public event EventHandler onAdVideoProgressEvent; + public event EventHandler onAdCloseEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler 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 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)); + + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATNativeBannerAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATNativeBannerAdClient.cs.meta new file mode 100644 index 0000000..2b436ed --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATNativeBannerAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2d7cc19b4b7cf4a57b79dabdbdb94d2c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATRewardedVideoAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATRewardedVideoAdClient.cs new file mode 100644 index 0000000..5a26c38 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATRewardedVideoAdClient.cs @@ -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 onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdVideoStartEvent; + public event EventHandler onAdVideoEndEvent; + public event EventHandler onAdVideoFailureEvent; + public event EventHandler onAdVideoCloseEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onRewardEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler onAdSourceBiddingFailureEvent; + public event EventHandler onPlayAgainStart; + public event EventHandler onPlayAgainEnd; + public event EventHandler onPlayAgainFailure; + public event EventHandler onPlayAgainClick; + public event EventHandler 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)); + } + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATRewardedVideoAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATRewardedVideoAdClient.cs.meta new file mode 100644 index 0000000..001aa01 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATRewardedVideoAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8b30dac781c4344df9754e38cf6472cc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATSDKAPIClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATSDKAPIClient.cs new file mode 100644 index 0000000..3209269 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATSDKAPIClient.cs @@ -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))] + static public int DidGetUserLocation(string location) + { + if (locationListener != null) { locationListener.didGetUserLocation(Int32.Parse(location)); } + return 0; + } + + [MonoPInvokeCallback(typeof(Func))] + static public int DidUMP(string location) + { + if (umpListener != null) { umpListener.onConsentDismiss(); } + return 0; + } + + [MonoPInvokeCallback(typeof(Func))] + 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); + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATSDKAPIClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATSDKAPIClient.cs.meta new file mode 100644 index 0000000..3d01689 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATSDKAPIClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6b455aa433ae6420a9e71c7b0475cb60 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATSplashAdClient.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATSplashAdClient.cs new file mode 100644 index 0000000..227ea33 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATSplashAdClient.cs @@ -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 onAdLoadEvent; + public event EventHandler onAdLoadFailureEvent; + public event EventHandler onAdShowEvent; + public event EventHandler onAdShowFailureEvent; + public event EventHandler onAdCloseEvent; + public event EventHandler onAdClickEvent; + public event EventHandler onAdVideoStartEvent; + public event EventHandler onAdVideoFailureEvent; + public event EventHandler onAdVideoEndEvent; + public event EventHandler onAdSourceAttemptEvent; + public event EventHandler onAdSourceFilledEvent; + public event EventHandler onAdSourceLoadFailureEvent; + public event EventHandler onAdSourceBiddingAttemptEvent; + public event EventHandler onAdSourceBiddingFilledEvent; + public event EventHandler onAdSourceBiddingFailureEvent; + public event EventHandler onAdLoadTimeoutEvent; + public event EventHandler onDeeplinkEvent; + public event EventHandler 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); + } + + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATSplashAdClient.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATSplashAdClient.cs.meta new file mode 100644 index 0000000..b4e1463 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/ATSplashAdClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 480a1fa0d5e0e4783be24ce7ff84b3a0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal.meta new file mode 100644 index 0000000..0b841d6 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5e1a828ee252c4a6bb226d2e51fcd5aa +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C.meta new file mode 100644 index 0000000..412502b --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4d98d4308064f4d08b78dd057af3bb59 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATAutolayoutCategories.h b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATAutolayoutCategories.h new file mode 100644 index 0000000..17ab2a9 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATAutolayoutCategories.h @@ -0,0 +1,27 @@ +// +// ATAutolayoutCategories.h +// ATSDKDemo +// +// Created by Martin Lau on 24/04/2018. +// Copyright © 2018 Martin Lau. All rights reserved. +// + +#import + +@interface UIView(Autolayout) ++(instancetype) autolayoutView; +- (NSArray<__kindof NSLayoutConstraint *> *)addConstraintsWithVisualFormat:(NSString *)format options:(NSLayoutFormatOptions)opts metrics:(NSDictionary *)metrics views:(NSDictionary *)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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATAutolayoutCategories.h.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATAutolayoutCategories.h.meta new file mode 100644 index 0000000..cf059b4 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATAutolayoutCategories.h.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATAutolayoutCategories.m b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATAutolayoutCategories.m new file mode 100644 index 0000000..28f3856 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATAutolayoutCategories.m @@ -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 *)metrics views:(NSDictionary *)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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATAutolayoutCategories.m.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATAutolayoutCategories.m.meta new file mode 100644 index 0000000..3452598 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATAutolayoutCategories.m.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBannerAdWrapper.h b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBannerAdWrapper.h new file mode 100644 index 0000000..7029c19 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBannerAdWrapper.h @@ -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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBannerAdWrapper.h.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBannerAdWrapper.h.meta new file mode 100644 index 0000000..b42ad7a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBannerAdWrapper.h.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBannerAdWrapper.m b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBannerAdWrapper.m new file mode 100644 index 0000000..7e8b68d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBannerAdWrapper.m @@ -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 +#import "ATUnityUtilities.h" +//5.6.6版本以上支持 admob 自适应banner (用到时再import该头文件) +//#import + +@interface ATBannerAdWrapper() +@property(nonatomic, readonly) NSMutableDictionary *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 dictionary]; + } + return self; +} + +-(NSString*) scriptWrapperClass { + return @"ATBannerAdWrapper"; +} + +- (id)selWrapperClassWithDict:(NSDictionary *)dict callback:(void(*)(const char*, const char*))callback { + NSString *selector = dict[@"selector"]; + NSArray* 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* 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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBannerAdWrapper.m.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBannerAdWrapper.m.meta new file mode 100644 index 0000000..864c57f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBannerAdWrapper.m.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBaseUnityWrapper.h b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBaseUnityWrapper.h new file mode 100644 index 0000000..641e16c --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBaseUnityWrapper.h @@ -0,0 +1,16 @@ +// +// ATBaseUnityWrapper.h +// UnityContainer +// +// Created by Martin Lau on 08/08/2018. +// Copyright © 2018 Martin Lau. All rights reserved. +// + +#import +#import "ATUnityWrapper.h" +@interface ATBaseUnityWrapper : NSObject +-(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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBaseUnityWrapper.h.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBaseUnityWrapper.h.meta new file mode 100644 index 0000000..b9aa2cc --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBaseUnityWrapper.h.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBaseUnityWrapper.m b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBaseUnityWrapper.m new file mode 100644 index 0000000..5143a79 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBaseUnityWrapper.m @@ -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 *callbacks; +@end +@implementation ATBaseUnityWrapper ++(instancetype) sharedInstance { + return nil; +} + +-(instancetype) init { + self = [super init]; + if (self != nil) { + _callbacks = [ATUnitySafeThreadDictionary 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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBaseUnityWrapper.m.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBaseUnityWrapper.m.meta new file mode 100644 index 0000000..672d35d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATBaseUnityWrapper.m.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATInterstitialAdWrapper.h b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATInterstitialAdWrapper.h new file mode 100644 index 0000000..3d6ac58 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATInterstitialAdWrapper.h @@ -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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATInterstitialAdWrapper.h.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATInterstitialAdWrapper.h.meta new file mode 100644 index 0000000..2b6c9c2 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATInterstitialAdWrapper.h.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATInterstitialAdWrapper.m b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATInterstitialAdWrapper.m new file mode 100644 index 0000000..edf6f0e --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATInterstitialAdWrapper.m @@ -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 + +NSString *const kLoadUseRVAsInterstitialKey = @"UseRewardedVideoAsInterstitial"; +NSString *const kInterstitialExtraAdSizeKey = @"interstitial_ad_size"; +static NSString *kATInterstitialSizeUsesPixelFlagKey = @"uses_pixel"; + +@interface ATInterstitialAdWrapper() +@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* 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* 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* 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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATInterstitialAdWrapper.m.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATInterstitialAdWrapper.m.meta new file mode 100644 index 0000000..2b519d6 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATInterstitialAdWrapper.m.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeAdWrapper.h b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeAdWrapper.h new file mode 100644 index 0000000..ea8416a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeAdWrapper.h @@ -0,0 +1,34 @@ +// +// ATNativeAdWrapper.h +// UnityContainer +// +// Created by Martin Lau on 27/07/2018. +// Copyright © 2018 Martin Lau. All rights reserved. +// + +#import +#import "ATBaseUnityWrapper.h" +#import + +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 + +@end diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeAdWrapper.h.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeAdWrapper.h.meta new file mode 100644 index 0000000..fc0b350 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeAdWrapper.h.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeAdWrapper.m b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeAdWrapper.m new file mode 100644 index 0000000..2d804d7 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeAdWrapper.m @@ -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 +#import +#import +#import +#import +#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 *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 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* 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* 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 *)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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeAdWrapper.m.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeAdWrapper.m.meta new file mode 100644 index 0000000..a35b0dd --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeAdWrapper.m.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeSelfRenderView.h b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeSelfRenderView.h new file mode 100644 index 0000000..9f97b7e --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeSelfRenderView.h @@ -0,0 +1,34 @@ +// +// ATNativeSelfRenderView.h +// AnyThinkSDKDemo +// +// Created by GUO PENG on 2022/5/7. +// Copyright © 2022 AnyThink. All rights reserved. +// + +#import +#import + + +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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeSelfRenderView.h.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeSelfRenderView.h.meta new file mode 100644 index 0000000..65ed454 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeSelfRenderView.h.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeSelfRenderView.m b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeSelfRenderView.m new file mode 100644 index 0000000..8e22d30 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeSelfRenderView.m @@ -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 +#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 *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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeSelfRenderView.m.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeSelfRenderView.m.meta new file mode 100644 index 0000000..4615b28 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATNativeSelfRenderView.m.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATRewardedVideoWrapper.h b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATRewardedVideoWrapper.h new file mode 100644 index 0000000..5fa1cb5 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATRewardedVideoWrapper.h @@ -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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATRewardedVideoWrapper.h.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATRewardedVideoWrapper.h.meta new file mode 100644 index 0000000..bd8f924 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATRewardedVideoWrapper.h.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATRewardedVideoWrapper.m b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATRewardedVideoWrapper.m new file mode 100644 index 0000000..fac3d97 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATRewardedVideoWrapper.m @@ -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 + +NSString *const kLoadExtraUserIDKey = @"UserId"; +NSString *const kLoadExtraMediaExtraKey = @"UserExtraData"; +@interface ATRewardedVideoWrapper() +@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* 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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATRewardedVideoWrapper.m.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATRewardedVideoWrapper.m.meta new file mode 100644 index 0000000..15feefe --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATRewardedVideoWrapper.m.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATSplashAdWrapper.h b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATSplashAdWrapper.h new file mode 100644 index 0000000..b8857c2 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATSplashAdWrapper.h @@ -0,0 +1,18 @@ +// +// ATSplashAdWrapper.h +// UnityFramework +// +// Created by li zhixuan on 2023/5/4. +// + +#import + +#import "ATBaseUnityWrapper.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface ATSplashAdWrapper : ATBaseUnityWrapper + +@end + +NS_ASSUME_NONNULL_END diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATSplashAdWrapper.h.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATSplashAdWrapper.h.meta new file mode 100644 index 0000000..9dbe7c9 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATSplashAdWrapper.h.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATSplashAdWrapper.m b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATSplashAdWrapper.m new file mode 100644 index 0000000..44b6529 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATSplashAdWrapper.m @@ -0,0 +1,239 @@ +// +// ATSplashAdWrapper.m +// UnityFramework +// +// Created by li zhixuan on 2023/5/4. +// + +#import "ATSplashAdWrapper.h" +#import "ATUnityUtilities.h" +#import + +@interface ATSplashAdWrapper () + +@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* 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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATSplashAdWrapper.m.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATSplashAdWrapper.m.meta new file mode 100644 index 0000000..e7e78cc --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATSplashAdWrapper.m.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityManager.h b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityManager.h new file mode 100644 index 0000000..35e593a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityManager.h @@ -0,0 +1,15 @@ +// +// ATUnityManager.h +// UnityContainer +// +// Created by Martin Lau on 08/08/2018. +// Copyright © 2018 Martin Lau. All rights reserved. +// + +#import +#import "ATUnityWrapper.h" + +@interface ATUnityManager : NSObject ++(instancetype)sharedInstance; +- (id)selWrapperClassWithDict:(NSDictionary *)dict callback:(void(*)(const char*))callback; +@end diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityManager.h.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityManager.h.meta new file mode 100644 index 0000000..4fee404 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityManager.h.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityManager.m b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityManager.m new file mode 100644 index 0000000..1fcf355 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityManager.m @@ -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 +#import "ATUnityUtilities.h" +#import +#import +#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* 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* mintegralInfo = [NSMutableDictionary 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 + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityManager.m.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityManager.m.meta new file mode 100644 index 0000000..1b23727 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityManager.m.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnitySafeThreadDictionary.h b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnitySafeThreadDictionary.h new file mode 100644 index 0000000..0d92efe --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnitySafeThreadDictionary.h @@ -0,0 +1,22 @@ +// ATSafeThreadDictionary.h +// ATSDK +// +// Created by topon on 2020/9/21. +// Copyright © 2020 AnyThink. All rights reserved. +// + +#import + +/** + 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 : NSMutableDictionary + +@end diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnitySafeThreadDictionary.h.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnitySafeThreadDictionary.h.meta new file mode 100644 index 0000000..fd14912 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnitySafeThreadDictionary.h.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnitySafeThreadDictionary.m b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnitySafeThreadDictionary.m new file mode 100644 index 0000000..76e59f7 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnitySafeThreadDictionary.m @@ -0,0 +1,261 @@ +// ATSafeThreadDictionary.h +// ATSDK +// +// Created by topon on 2020/9/21. +// Copyright © 2020 AnyThink. All rights reserved. +// + +#import "ATUnitySafeThreadDictionary.h" +#import + + +#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 [])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 )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 )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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnitySafeThreadDictionary.m.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnitySafeThreadDictionary.m.meta new file mode 100644 index 0000000..d26a6b8 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnitySafeThreadDictionary.m.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityUtilities.h b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityUtilities.h new file mode 100644 index 0000000..a6a3299 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityUtilities.h @@ -0,0 +1,51 @@ +// +// ATUnityUtilities.h +// UnityContainer +// +// Created by Martin Lau on 14/08/2018. +// Copyright © 2018 Martin Lau. All rights reserved. +// + +#import +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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityUtilities.h.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityUtilities.h.meta new file mode 100644 index 0000000..a32cd41 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityUtilities.h.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityUtilities.m b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityUtilities.m new file mode 100644 index 0000000..52f5325 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityUtilities.m @@ -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 diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityUtilities.m.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityUtilities.m.meta new file mode 100644 index 0000000..62df7c0 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityUtilities.m.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityWrapper.h b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityWrapper.h new file mode 100644 index 0000000..cfa155d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityWrapper.h @@ -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 ++(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 */ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityWrapper.h.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityWrapper.h.meta new file mode 100644 index 0000000..1144421 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/C/ATUnityWrapper.h.meta @@ -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: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script.meta new file mode 100644 index 0000000..d68f3de --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 63ad3d5c2457e4cc0a4ec3cb55871ab0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATAdWrapper.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATAdWrapper.cs new file mode 100644 index 0000000..5a2da54 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATAdWrapper.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; +public class ATAdWrapper { + public ATAdWrapper() { + } + + public static void InvokeCallback(string callback, Dictionary msgDict) { + + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATAdWrapper.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATAdWrapper.cs.meta new file mode 100644 index 0000000..f9d6069 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATAdWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5c2551e3191c44d8a8c60bb3b9a405cd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATBannerAdWrapper.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATBannerAdWrapper.cs new file mode 100644 index 0000000..69613f3 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATBannerAdWrapper.cs @@ -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 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 msgDict = JsonMapper.ToObject>(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 errorMsg = JsonMapper.ToObject>(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 errorMsg = JsonMapper.ToObject>(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 errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(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 errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(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 rectDict = new Dictionary { { "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 rectDict = new Dictionary { { "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 rectDict = new Dictionary{ {"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 rectDict = new Dictionary{ {"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(); + 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 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 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"]); + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATBannerAdWrapper.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATBannerAdWrapper.cs.meta new file mode 100644 index 0000000..967b30f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATBannerAdWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3d08bff91e9f04e70a5d9b9cd12246c2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATInterstitialAdWrapper.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATInterstitialAdWrapper.cs new file mode 100644 index 0000000..5631584 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATInterstitialAdWrapper.cs @@ -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 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 msgDict = JsonMapper.ToObject>(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 errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(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 errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(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 errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(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 errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(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(); + 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 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 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 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 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}); + } + + + +} + + + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATInterstitialAdWrapper.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATInterstitialAdWrapper.cs.meta new file mode 100644 index 0000000..851bcd9 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATInterstitialAdWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 711645adb26aa4e719452c22c119860a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATManager.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATManager.cs new file mode 100644 index 0000000..65cce52 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATManager.cs @@ -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 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 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 callback) + { + Debug.Log("Unity:ATManager::showGDPRConsentDialog()"); + ATUnityCBridge.SendMessageToCWithCallBack("ATUnityManager", "showGDPRConsentDialog:", new object[] { }, callback); + } + +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATManager.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATManager.cs.meta new file mode 100644 index 0000000..73ccb21 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 03eb4e943127141c59f535e435de167a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATNativeAdWrapper.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATNativeAdWrapper.cs new file mode 100644 index 0000000..5869b98 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATNativeAdWrapper.cs @@ -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 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 msgDict = JsonMapper.ToObject>(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 errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(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 errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(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 errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(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(); + 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 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 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 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"]); + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATNativeAdWrapper.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATNativeAdWrapper.cs.meta new file mode 100644 index 0000000..61598f6 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATNativeAdWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d38a08729c61f4446b3db4df409d9d67 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATNativeBannerAdWrapper.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATNativeBannerAdWrapper.cs new file mode 100644 index 0000000..fc168b1 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATNativeBannerAdWrapper.cs @@ -0,0 +1,131 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System; +using AOT; +using AnyThinkAds.ThirdParty.LitJson; +using AnyThinkAds.iOS; +using AnyThinkAds.Api; +#pragma warning disable 0109 +public class ATNativeBannerAdWrapper : ATAdWrapper { + static private Dictionary clients; + static private string CMessageReceiverClass = "ATNativeBannerAdWrapper"; + + static public new void InvokeCallback(JsonData jsonData) { + Debug.Log("Unity: ATNativeBannerAdWrapper::InvokeCallback()"); + string extraJson = ""; + string callback = (string)jsonData["callback"]; + Dictionary msgDict = JsonMapper.ToObject>(jsonData["msg"].ToJson()); + JsonData msgJsonData = jsonData["msg"]; + IDictionary idic = (System.Collections.IDictionary)msgJsonData; + + if (idic.Contains("extra")) { + JsonData extraJsonDate = msgJsonData["extra"]; + if (extraJsonDate != null) { + extraJson = msgJsonData["extra"].ToJson(); + } + } + + if (callback.Equals("OnNativeBannerAdLoaded")) { + OnNativeBannerAdLoaded((string)msgDict["placement_id"]); + } else if (callback.Equals("OnNativeBannerAdLoadingFailure")) { + Dictionary errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(msgJsonData["error"].ToJson()); + if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); } + if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); } + OnNativeBannerAdLoadingFailure((string)msgDict["placement_id"], errorDict); + } else if (callback.Equals("OnNaitveBannerAdShow")) { + OnNaitveBannerAdShow((string)msgDict["placement_id"], extraJson); + } else if (callback.Equals("OnNativeBannerAdClick")) { + OnNativeBannerAdClick((string)msgDict["placement_id"], extraJson); + } else if (callback.Equals("OnNativeBannerAdAutorefresh")) { + OnNativeBannerAdAutorefresh((string)msgDict["placement_id"], extraJson); + } else if (callback.Equals("OnNativeBannerAdAutorefreshFailed")) { + Dictionary errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(msgJsonData["error"].ToJson()); + if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); } + if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); } + OnNativeBannerAdAutorefreshFailed((string)msgDict["placement_id"], errorDict); + } else if (callback.Equals("OnNativeBannerAdCloseButtonClicked")) { + OnNativeBannerAdCloseButtonClicked((string)msgDict["placement_id"]); + } else if (callback.Equals("PauseAudio")) { + Debug.Log("c# : callback, PauseAudio"); + PauseAudio(); + } else if (callback.Equals("ResumeAudio")) { + Debug.Log("c# : callback, ResumeAudio"); + ResumeAudio(); + } + } + + static public void PauseAudio() { + Debug.Log("ATNativeBannerAdWrapper::PauseAudio()"); + } + + static public void ResumeAudio() { + Debug.Log("ATNativeBannerAdWrapper::ResumeAudio()"); + } + + static public void setClientForPlacementID(string placementID, ATNativeBannerAdClient client) { + Debug.Log("ATNativeBannerAdWrapper::setClientForPlacementID()"); + if (clients == null) clients = new Dictionary(); + if (clients.ContainsKey(placementID)) clients.Remove(placementID); + clients.Add(placementID, client); + } + + static public void loadAd(string placementID, string customData) { + Debug.Log("ATNativeBannerAdWrapper::loadAd()"); + ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "loadNativeBannerAdWithPlacementID:customDataJSONString:callback:", new object[]{placementID, customData != null ? customData : ""}, true); + } + + static public bool adReady(string placementID) { + Debug.Log("ATNativeBannerAdWrapper::adReady()"); + return ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "isNativeBannerAdReadyForPlacementID:", new object[]{placementID}); + } + + static public void showAd(string placementID, ATRect rect, Dictionary pairs) { + Debug.Log("ATNativeBannerAdWrapper::showAd()"); + Dictionary rectDict = new Dictionary{ {"x", rect.x}, {"y", rect.y}, {"width", rect.width}, {"height", rect.height} }; + ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "showNativeBannerAdWithPlacementID:rect:extra:", new object[]{placementID, JsonMapper.ToJson(rectDict), JsonMapper.ToJson(pairs != null ? pairs : new Dictionary())}, false); + } + + static public void removeAd(string placementID) { + Debug.Log("ATNativeBannerAdWrapper::removeAd()"); + ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "removeNativeBannerAdWithPlacementID:", new object[]{placementID}, false); + } + + //Callbacks + static private void OnNativeBannerAdLoaded(string placementID) { + Debug.Log("Unity: ATNativeBannerAdWrapper::OnNativeBannerAdLoaded(" + placementID + ")"); + if (clients[placementID] != null) clients[placementID].onAdLoaded(placementID); + } + + static private void OnNativeBannerAdLoadingFailure(string placementID, Dictionary errorDict) { + Debug.Log("Unity: ATNativeBannerAdWrapper::OnNativeBannerAdLoadingFailure(" + placementID + ")"); + if (clients[placementID] != null) clients[placementID].onAdLoadFail(placementID, (string)errorDict["code"], (string)errorDict["message"]); + } + + static private void OnNaitveBannerAdShow(string placementID, string callbackJson) { + Debug.Log("Unity: ATNativeBannerAdWrapper::OnNaitveBannerAdShow(" + placementID + ")"); + if (clients[placementID] != null) clients[placementID].onAdImpressed(placementID, callbackJson); + } + + static private void OnNativeBannerAdClick(string placementID, string callbackJson) { + Debug.Log("Unity: ATNativeBannerAdWrapper::OnNativeBannerAdClick(" + placementID + ")"); + if (clients[placementID] != null) clients[placementID].onAdClicked(placementID, callbackJson); + } + + static private void OnNativeBannerAdAutorefresh(string placementID, string callbackJson) { + Debug.Log("Unity: ATNativeBannerAdWrapper::OnNativeBannerAdAutorefresh(" + placementID + ")"); + if (clients[placementID] != null) clients[placementID].onAdAutoRefresh(placementID, callbackJson); + } + + static private void OnNativeBannerAdAutorefreshFailed(string placementID, Dictionary errorDict) { + Debug.Log("Unity: ATNativeBannerAdWrapper::OnNativeBannerAdAutorefreshFailed(" + placementID + ")"); + if (clients[placementID] != null) clients[placementID].onAdAutoRefreshFailure(placementID, (string)errorDict["code"], (string)errorDict["message"]); + } + + static private void OnNativeBannerAdCloseButtonClicked(string placementID) { + Debug.Log("Unity: ATNativeBannerAdWrapper::OnNativeBannerAdCloseButtonClicked(" + placementID + ")"); + if (clients[placementID] != null) clients[placementID].onAdCloseButtonClicked(placementID); + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATNativeBannerAdWrapper.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATNativeBannerAdWrapper.cs.meta new file mode 100644 index 0000000..c17133c --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATNativeBannerAdWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c5f14ce974a86410c9ea19cd7764139e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATRewardedVideoWrapper.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATRewardedVideoWrapper.cs new file mode 100644 index 0000000..b7ce57c --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATRewardedVideoWrapper.cs @@ -0,0 +1,313 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System; +using AOT; +using AnyThinkAds.ThirdParty.LitJson; +using AnyThinkAds.iOS; +#pragma warning disable 0109 +public class ATRewardedVideoWrapper:ATAdWrapper { + static private Dictionary clients; + static private string CMessageReceiverClass = "ATRewardedVideoWrapper"; + + static public new void InvokeCallback(JsonData jsonData) { + Debug.Log("Unity: ATRewardedVideoWrapper::InvokeCallback()"); + string extraJson = ""; + string callback = (string)jsonData["callback"]; + Dictionary msgDict = JsonMapper.ToObject>(jsonData["msg"].ToJson()); + JsonData msgJsonData = jsonData["msg"]; + IDictionary idic = (System.Collections.IDictionary)msgJsonData; + + if (idic.Contains("extra")) { + JsonData extraJsonDate = msgJsonData["extra"]; + if (extraJsonDate != null) { + extraJson = msgJsonData["extra"].ToJson(); + } + } + + if (callback.Equals("OnRewardedVideoLoaded")) { + OnRewardedVideoLoaded((string)msgDict["placement_id"]); + } else if (callback.Equals("OnRewardedVideoLoadFailure")) { + + Dictionary errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(msgJsonData["error"].ToJson()); + if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); } + if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); } + OnRewardedVideoLoadFailure((string)msgDict["placement_id"], errorDict); + + } else if (callback.Equals("OnRewardedVideoPlayFailure")) { + Dictionary errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(msgJsonData["error"].ToJson()); + if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); } + if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); } + OnRewardedVideoPlayFailure((string)msgDict["placement_id"], errorDict); + } else if (callback.Equals("OnRewardedVideoPlayStart")) { + OnRewardedVideoPlayStart((string)msgDict["placement_id"], extraJson); + } else if (callback.Equals("OnRewardedVideoPlayEnd")) { + OnRewardedVideoPlayEnd((string)msgDict["placement_id"], extraJson); + } else if (callback.Equals("OnRewardedVideoClick")) { + OnRewardedVideoClick((string)msgDict["placement_id"], extraJson); + } else if (callback.Equals("OnRewardedVideoClose")) { + OnRewardedVideoClose((string)msgDict["placement_id"], (bool)msgDict["rewarded"], extraJson); + } else if (callback.Equals("OnRewardedVideoReward")) { + OnRewardedVideoReward((string)msgDict["placement_id"], extraJson); + } else if (callback.Equals("OnRewardedVideoAdAgainPlayStart")) { + OnRewardedVideoAdAgainPlayStart((string)msgDict["placement_id"], extraJson); + } else if (callback.Equals("OnRewardedVideoAdAgainPlayEnd")) { + OnRewardedVideoAdAgainPlayEnd((string)msgDict["placement_id"], extraJson); + } else if (callback.Equals("OnRewardedVideoAdAgainPlayFailed")) { + Dictionary errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(msgJsonData["error"].ToJson()); + if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); } + if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); } + OnRewardedVideoAdAgainPlayFailed((string)msgDict["placement_id"], errorDict); + } else if (callback.Equals("OnRewardedVideoAdAgainPlayClicked")) { + OnRewardedVideoAdAgainPlayClicked((string)msgDict["placement_id"], extraJson); + }else if (callback.Equals("OnAgainReward")) { + OnAgainReward((string)msgDict["placement_id"], extraJson); + }else if (callback.Equals("startLoadingADSource")) { + StartLoadingADSource((string)msgDict["placement_id"], extraJson); + }else if (callback.Equals("finishLoadingADSource")) { + FinishLoadingADSource((string)msgDict["placement_id"], extraJson); + }else if (callback.Equals("failToLoadADSource")) { + Dictionary errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(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 errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(msgJsonData["error"].ToJson()); + if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); } + if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); } + FailBiddingADSource((string)msgDict["placement_id"],extraJson, errorDict); + } + + + } + + //Public method(s) + static public void setClientForPlacementID(string placementID, ATRewardedVideoAdClient client) { + if (clients == null) clients = new Dictionary(); + if (clients.ContainsKey(placementID)) clients.Remove(placementID); + clients.Add(placementID, client); + } + + static public void setExtra(Dictionary extra) { + Debug.Log("Unity: ATRewardedVideoWrapper::setExtra()"); + ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "setExtra:", new object[]{extra}); + } + + static public void loadRewardedVideo(string placementID, string customData) { + Debug.Log("Unity: ATRewardedVideoWrapper::loadRewardedVideo(" + placementID + ")"); + ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "loadRewardedVideoWithPlacementID:customDataJSONString:callback:", new object[]{placementID, customData != null ? customData : ""}, true); + } + + static public bool isRewardedVideoReady(string placementID) { + Debug.Log("Unity: ATRewardedVideoWrapper::isRewardedVideoReady(" + placementID + ")"); + return ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "rewardedVideoReadyForPlacementID:", new object[]{placementID}); + } + + static public void showRewardedVideo(string placementID, string mapJson) { + Debug.Log("Unity: ATRewardedVideoWrapper::showRewardedVideo(" + placementID + ")"); + ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "showRewardedVideoWithPlacementID:extraJsonString:", new object[]{placementID, mapJson}); + } + + static public void clearCache() { + Debug.Log("Unity: ATRewardedVideoWrapper::clearCache()"); + ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "clearCache", null); + } + + static public string checkAdStatus(string placementID) { + Debug.Log("Unity: ATRewardedVideoWrapper::checkAdStatus(" + placementID + ")"); + return ATUnityCBridge.GetStringMessageFromC(CMessageReceiverClass, "checkAdStatus:", new object[]{placementID}); + } + + static public string getValidAdCaches(string placementID) + { + Debug.Log("Unity: ATRewardedVideoWrapper::getValidAdCaches(" + placementID + ")"); + return ATUnityCBridge.GetStringMessageFromC(CMessageReceiverClass, "getValidAdCaches:", new object[] { placementID }); + } + + static public void entryScenarioWithPlacementID(string placementID, string scenarioID) + { + Debug.Log("Unity: ATRewardedVideoWrapper::entryScenarioWithPlacementID(" + placementID + scenarioID + ")"); + ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "entryScenarioWithPlacementID:scenarioID:", new object[]{placementID, scenarioID}); + } + + //Callbacks + static public void OnRewardedVideoLoaded(string placementID) { + Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoLoaded()"); + if (clients[placementID] != null) clients[placementID].onRewardedVideoAdLoaded(placementID); + } + + static public void OnRewardedVideoLoadFailure(string placementID, Dictionary errorDict) { + Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoLoadFailure()"); + Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict)); + if (clients[placementID] != null) clients[placementID].onRewardedVideoAdFailed(placementID, (string)errorDict["code"], (string)errorDict["message"]); + } + + static public void OnRewardedVideoPlayFailure(string placementID, Dictionary errorDict) { + Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoPlayFailure()"); + if (clients[placementID] != null) clients[placementID].onRewardedVideoAdPlayFailed(placementID, (string)errorDict["code"], (string)errorDict["message"]); + + } + + static public void OnRewardedVideoPlayStart(string placementID, string callbackJson) { + Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoPlayStart()"); + if (clients[placementID] != null) clients[placementID].onRewardedVideoAdPlayStart(placementID, callbackJson); + } + + static public void OnRewardedVideoPlayEnd(string placementID, string callbackJson) { + Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoPlayEnd()"); + if (clients[placementID] != null) clients[placementID].onRewardedVideoAdPlayEnd(placementID, callbackJson); + } + + static public void OnRewardedVideoClick(string placementID, string callbackJson) { + Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoClick()"); + if (clients[placementID] != null) clients[placementID].onRewardedVideoAdPlayClicked(placementID, callbackJson); + } + + static public void OnRewardedVideoClose(string placementID, bool rewarded, string callbackJson) { + Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoClose()"); + if (clients[placementID] != null) clients[placementID].onRewardedVideoAdClosed(placementID, rewarded, callbackJson); + } + static public void OnRewardedVideoReward(string placementID, string callbackJson) + { + Debug.Log("Unity: ATRewardedVideoWrapper::OnRewardedVideoReward()"); + if (clients[placementID] != null) clients[placementID].onRewardedVideoReward(placementID, callbackJson); + } + + //------again callback + static public void OnRewardedVideoAdAgainPlayStart(string placementID, string callbackJson) + { + Debug.Log("Unity: ATRewardedVideoWrapper::onRewardedVideoAdAgainPlayStart()"); + if (clients[placementID] != null) clients[placementID].onRewardedVideoAdAgainPlayStart(placementID, callbackJson); + } + + + static public void OnRewardedVideoAdAgainPlayEnd(string placementID, string callbackJson) + { + Debug.Log("Unity: ATRewardedVideoWrapper::onRewardedVideoAdAgainPlayEnd()"); + if (clients[placementID] != null) clients[placementID].onRewardedVideoAdAgainPlayEnd(placementID, callbackJson); + } + + + static public void OnRewardedVideoAdAgainPlayFailed(string placementID, Dictionary errorDict) + { + Debug.Log("Unity: ATRewardedVideoWrapper::onRewardedVideoAdAgainPlayFailed()"); + if (clients[placementID] != null) clients[placementID].onRewardedVideoAdAgainPlayFailed(placementID, (string)errorDict["code"], (string)errorDict["message"]); + } + + + static public void OnRewardedVideoAdAgainPlayClicked(string placementID, string callbackJson) + { + Debug.Log("Unity: ATRewardedVideoWrapper::onRewardedVideoAdAgainPlayClicked()"); + if (clients[placementID] != null) clients[placementID].onRewardedVideoAdAgainPlayClicked(placementID, callbackJson); + } + + + static public void OnAgainReward(string placementID, string callbackJson) + { + Debug.Log("Unity: ATRewardedVideoWrapper::onAgainReward()"); + if (clients[placementID] != null) clients[placementID].onAgainReward(placementID, callbackJson); + } + + // Auto + static public void addAutoLoadAdPlacementID(string placementID) + { + Debug.Log("Unity: ATRewardedVideoWrapper::addAutoLoadAdPlacementID(" + placementID + ")"); + ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "addAutoLoadAdPlacementID:callback:", new object[]{placementID}, true); + } + + static public void removeAutoLoadAdPlacementID(string placementID) + { + Debug.Log("Unity: ATRewardedVideoWrapper::removeAutoLoadAdPlacementID(" + placementID + ")"); + ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "removeAutoLoadAdPlacementID:", new object[]{placementID}); + } + static public bool autoLoadRewardedVideoReadyForPlacementID(string placementID) + { + Debug.Log("Unity: ATRewardedVideoWrapper::autoLoadRewardedVideoReadyForPlacementID(" + placementID + ")"); + return ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "autoLoadRewardedVideoReadyForPlacementID:", new object[]{placementID}); + } + static public string getAutoValidAdCaches(string placementID) + { + Debug.Log("Unity: ATRewardedVideoWrapper::getAutoValidAdCaches"); + return ATUnityCBridge.GetStringMessageFromC(CMessageReceiverClass, "getAutoValidAdCaches:", new object[]{placementID}); + } + + static public string checkAutoAdStatus(string placementID) { + Debug.Log("Unity: ATRewardedVideoWrapper::checkAutoAdStatus(" + placementID + ")"); + return ATUnityCBridge.GetStringMessageFromC(CMessageReceiverClass, "checkAutoAdStatus:", new object[]{placementID}); + } + + static public void setAutoLocalExtra(string placementID, string customData) + { + + Debug.Log("Unity: ATRewardedVideoWrapper::setAutoLocalExtra(" + placementID + customData + ")"); + ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "setAutoLocalExtra:customDataJSONString:", new object[] {placementID, customData != null ? customData : ""}); + } + + static public void entryAutoAdScenarioWithPlacementID(string placementID, string scenarioID) + { + Debug.Log("Unity: ATRewardedVideoWrapper::entryAutoAdScenarioWithPlacementID(" + placementID + scenarioID + ")"); + ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "entryAutoAdScenarioWithPlacementID:scenarioID:", new object[]{placementID, scenarioID}); + } + + static public void showAutoRewardedVideo(string placementID, string mapJson) { + Debug.Log("Unity: ATRewardedVideoWrapper::showAutoRewardedVideo(" + placementID + ")"); + ATUnityCBridge.SendMessageToC(CMessageReceiverClass, "showAutoRewardedVideoWithPlacementID:extraJsonString:", new object[]{placementID, mapJson}); + } + + // ad source callback + static public void StartLoadingADSource(string placementID, string callbackJson) + { + Debug.Log("Unity: ATRewardedVideoWrapper::StartLoadingADSource()"); + if (clients[placementID] != null) clients[placementID].startLoadingADSource(placementID, callbackJson); + } + static public void FinishLoadingADSource(string placementID, string callbackJson) + { + Debug.Log("Unity: ATRewardedVideoWrapper::FinishLoadingADSource()"); + if (clients[placementID] != null) clients[placementID].finishLoadingADSource(placementID, callbackJson); + } + + static public void FailToLoadADSource(string placementID, string callbackJson, Dictionary errorDict) + { + Debug.Log("Unity: ATRewardedVideoWrapper::FailToLoadADSource()"); + + Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict)); + if (clients[placementID] != null) clients[placementID].failToLoadADSource(placementID, callbackJson,(string)errorDict["code"], (string)errorDict["message"]); + } + + static public void StartBiddingADSource(string placementID, string callbackJson) + { + Debug.Log("Unity: ATRewardedVideoWrapper::StartBiddingADSource()"); + if (clients[placementID] != null) clients[placementID].startBiddingADSource(placementID, callbackJson); + } + static public void FinishBiddingADSource(string placementID, string callbackJson) + { + Debug.Log("Unity: ATRewardedVideoWrapper::FinishBiddingADSource()"); + if (clients[placementID] != null) clients[placementID].finishBiddingADSource(placementID, callbackJson); + } + + static public void FailBiddingADSource(string placementID, string callbackJson,Dictionary errorDict) + { + Debug.Log("Unity: ATRewardedVideoWrapper::FailBiddingADSource()"); + + Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict)); + if (clients[placementID] != null) clients[placementID].failBiddingADSource(placementID,callbackJson,(string)errorDict["code"], (string)errorDict["message"]); + } + + + + +} + + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATRewardedVideoWrapper.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATRewardedVideoWrapper.cs.meta new file mode 100644 index 0000000..4edc413 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATRewardedVideoWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9586267a5f7774beb9257263979b2039 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATSplashAdWrapper.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATSplashAdWrapper.cs new file mode 100644 index 0000000..690f95f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATSplashAdWrapper.cs @@ -0,0 +1,263 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System; +using AOT; +using AnyThinkAds.ThirdParty.LitJson; +using AnyThinkAds.iOS; +#pragma warning disable 0109 +public class ATSplashAdWrapper:ATAdWrapper { + static private Dictionary clients; + static private string CMessaageReceiverClass = "ATSplashAdWrapper"; + + static public new void InvokeCallback(JsonData jsonData) { + Debug.Log("Unity: ATSplashAdWrapper::InvokeCallback()"); + string extraJson = ""; + string callback = (string)jsonData["callback"]; + Dictionary msgDict = JsonMapper.ToObject>(jsonData["msg"].ToJson()); + JsonData msgJsonData = jsonData["msg"]; + IDictionary idic = (System.Collections.IDictionary)msgJsonData; + + if (idic.Contains("extra")) { + JsonData extraJsonDate = msgJsonData["extra"]; + if (extraJsonDate != null) { + extraJson = msgJsonData["extra"].ToJson(); + } + } + + if (callback.Equals("OnSplashAdLoaded")) { + OnSplashAdLoaded((string)msgDict["placement_id"]); + } else if (callback.Equals("OnSplashAdLoadFailure")) { + Dictionary errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(msgJsonData["error"].ToJson()); + if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); } + if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); } + OnSplashAdLoadFailure((string)msgDict["placement_id"], errorDict); + } else if (callback.Equals("OnSplashAdVideoPlayFailure")) { + Dictionary errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(msgJsonData["error"].ToJson()); + if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); } + if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); } + OnSplashAdVideoPlayFailure((string)msgDict["placement_id"], errorDict); + } else if (callback.Equals("OnSplashAdVideoPlayStart")) { + OnSplashAdVideoPlayStart((string)msgDict["placement_id"], extraJson); + } else if (callback.Equals("OnSplashAdVideoPlayEnd")) { + OnSplashAdVideoPlayEnd((string)msgDict["placement_id"], extraJson); + } else if (callback.Equals("OnSplashAdShow")) { + OnSplashAdShow((string)msgDict["placement_id"], extraJson); + } else if (callback.Equals("OnSplashAdClick")) { + OnSplashAdClick((string)msgDict["placement_id"], extraJson); + } else if (callback.Equals("OnSplashAdClose")) { + OnSplashAdClose((string)msgDict["placement_id"], extraJson); + } else if (callback.Equals("OnSplashAdFailedToShow")) { + OnSplashAdFailedToShow((string)msgDict["placement_id"]); + }else if (callback.Equals("startLoadingADSource")) { + StartLoadingADSource((string)msgDict["placement_id"], extraJson); + }else if (callback.Equals("finishLoadingADSource")) { + FinishLoadingADSource((string)msgDict["placement_id"], extraJson); + }else if (callback.Equals("failToLoadADSource")) { + + Dictionary errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(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 errorDict = new Dictionary(); + Dictionary errorMsg = JsonMapper.ToObject>(msgJsonData["error"].ToJson()); + if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); } + if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); } + FailBiddingADSource((string)msgDict["placement_id"],extraJson, errorDict); + } + + + } + + static public void setClientForPlacementID(string placementID, ATSplashAdClient client) { + if (clients == null) clients = new Dictionary(); + if (clients.ContainsKey(placementID)) clients.Remove(placementID); + clients.Add(placementID, client); + } + + static public void loadSplashAd(string placementID, string customData) { + Debug.Log("Unity: ATSplashAdWrapper::loadSplashAd(" + placementID + ")"); + ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "loadSplashAdWithPlacementID:customDataJSONString:callback:", new object[]{placementID, customData != null ? customData : ""}, true); + } + + static public bool hasSplashAdReady(string placementID) { + Debug.Log("Unity: ATSplashAdWrapper::isSplashAdReady(" + placementID + ")"); + return ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "splashAdReadyForPlacementID:", new object[]{placementID}); + } + + static public void showSplashAd(string placementID, string mapJson) { + Debug.Log("Unity: ATSplashAdWrapper::showSplashAd(" + placementID + ")"); + ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "showSplashAdWithPlacementID:extraJsonString:", new object[]{placementID, mapJson}); + } + + static public void clearCache(string placementID) { + Debug.Log("Unity: ATSplashAdWrapper::clearCache()"); + ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "clearCache", null); + } + + static public string checkAdStatus(string placementID) { + Debug.Log("Unity: ATSplashAdWrapper::checkAdStatus(" + placementID + ")"); + return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "checkAdStatus:", new object[]{placementID}); + } + + static public string getValidAdCaches(string placementID) + { + Debug.Log("Unity: ATSplashAdWrapper::checkAdStatus(" + placementID + ")"); + return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "getValidAdCaches:", new object[] { placementID }); + } + + static public void entryScenarioWithPlacementID(string placementID, string scenarioID) + { + Debug.Log("Unity: ATSplashAdWrapper::entryScenarioWithPlacementID(" + placementID + scenarioID + ")"); + ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "entryScenarioWithPlacementID:scenarioID:", new object[]{placementID, scenarioID}); + } + + //Callbacks + static private void OnSplashAdLoaded(string placementID) { + Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdLoaded()"); + if (clients[placementID] != null) clients[placementID].OnSplashAdLoaded(placementID); + } + + static private void OnSplashAdLoadFailure(string placementID, Dictionary errorDict) { + Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdLoadFailure()"); + Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict)); + if (clients[placementID] != null) clients[placementID].OnSplashAdLoadFailure(placementID, (string)errorDict["code"], (string)errorDict["message"]); + } + + static private void OnSplashAdVideoPlayFailure(string placementID, Dictionary errorDict) { + Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdVideoPlayFailure()"); + if (clients[placementID] != null) clients[placementID].OnSplashAdVideoPlayFailure(placementID, (string)errorDict["code"], (string)errorDict["message"]); + } + + static private void OnSplashAdVideoPlayStart(string placementID, string callbackJson) { + Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdPlayStart()"); + if (clients[placementID] != null) clients[placementID].OnSplashAdVideoPlayStart(placementID, callbackJson); + } + + static private void OnSplashAdVideoPlayEnd(string placementID, string callbackJson) { + Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdVideoPlayEnd()"); + if (clients[placementID] != null) clients[placementID].OnSplashAdVideoPlayEnd(placementID, callbackJson); + } + + static private void OnSplashAdShow(string placementID, string callbackJson) { + Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdShow()"); + if (clients[placementID] != null) clients[placementID].OnSplashAdShow(placementID, callbackJson); + } + + static private void OnSplashAdFailedToShow(string placementID) { + Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdFailedToShow()"); + if (clients[placementID] != null) clients[placementID].OnSplashAdFailedToShow(placementID); + } + + static private void OnSplashAdClick(string placementID, string callbackJson) { + Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdClick()"); + if (clients[placementID] != null) clients[placementID].OnSplashAdClick(placementID, callbackJson); + } + + static private void OnSplashAdClose(string placementID, string callbackJson) { + Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdClose()"); + if (clients[placementID] != null) clients[placementID].OnSplashAdClose(placementID, callbackJson); + } + // ad source callback + static public void StartLoadingADSource(string placementID, string callbackJson) + { + Debug.Log("Unity: ATSplashAdWrapper::StartLoadingADSource()"); + if (clients[placementID] != null) clients[placementID].startLoadingADSource(placementID, callbackJson); + } + static public void FinishLoadingADSource(string placementID, string callbackJson) + { + Debug.Log("Unity: ATSplashAdWrapper::FinishLoadingADSource()"); + if (clients[placementID] != null) clients[placementID].finishLoadingADSource(placementID, callbackJson); + } + + static public void FailToLoadADSource(string placementID,string callbackJson, Dictionary errorDict) + { + Debug.Log("Unity: ATSplashAdWrapper::FailToLoadADSource()"); + + Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict)); + if (clients[placementID] != null) clients[placementID].failToLoadADSource(placementID,callbackJson,(string)errorDict["code"], (string)errorDict["message"]); + } + + static public void StartBiddingADSource(string placementID, string callbackJson) + { + Debug.Log("Unity: ATSplashAdWrapper::StartBiddingADSource()"); + if (clients[placementID] != null) clients[placementID].startBiddingADSource(placementID, callbackJson); + } + static public void FinishBiddingADSource(string placementID, string callbackJson) + { + Debug.Log("Unity: ATSplashAdWrapper::FinishBiddingADSource()"); + if (clients[placementID] != null) clients[placementID].finishBiddingADSource(placementID, callbackJson); + } + + static public void FailBiddingADSource(string placementID, string callbackJson,Dictionary errorDict) + { + Debug.Log("Unity: ATSplashAdWrapper::FailBiddingADSource()"); + + Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict)); + if (clients[placementID] != null) clients[placementID].failBiddingADSource(placementID,callbackJson,(string)errorDict["code"], (string)errorDict["message"]); + } + + // Auto + static public void addAutoLoadAdPlacementID(string placementID) + { + Debug.Log("Unity: ATSplashAdWrapper::addAutoLoadAdPlacementID(" + placementID + ")"); + ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "addAutoLoadAdPlacementID:callback:", new object[]{placementID}, true); + } + + static public void removeAutoLoadAdPlacementID(string placementID) + { + Debug.Log("Unity: ATSplashAdWrapper::removeAutoLoadAdPlacementID(" + placementID + ")"); + ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "removeAutoLoadAdPlacementID:", new object[]{placementID}); + } + static public bool autoLoadSplashAdReadyForPlacementID(string placementID) + { + Debug.Log("Unity: ATSplashAdWrapper::autoLoadSplashAdReadyForPlacementID(" + placementID + ")"); + + return ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "autoLoadSplashAdReadyForPlacementID:", new object[]{placementID}); + } + static public string getAutoValidAdCaches(string placementID) + { + Debug.Log("Unity: ATSplashAdWrapper::getAutoValidAdCaches"); + return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "getAutoValidAdCaches:", new object[]{placementID}); + } + + static public string checkAutoAdStatus(string placementID) { + Debug.Log("Unity: ATSplashAdWrapper::checkAutoAdStatus(" + placementID + ")"); + return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "checkAutoAdStatus:", new object[]{placementID}); + } + + static public void setAutoLocalExtra(string placementID, string customData) + { + + Debug.Log("Unity: ATSplashAdWrapper::setAutoLocalExtra(" + placementID + customData + ")"); + ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "setAutoLocalExtra:customDataJSONString:", new object[] {placementID, customData != null ? customData : ""}); + } + + static public void entryAutoAdScenarioWithPlacementID(string placementID, string scenarioID) + { + Debug.Log("Unity: ATSplashAdWrapper::entryAutoAdScenarioWithPlacementID(" + placementID + scenarioID + ")"); + ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "entryAutoAdScenarioWithPlacementID:scenarioID:", new object[]{placementID, scenarioID}); + } + + static public void showAutoSplashAd(string placementID, string mapJson) { + Debug.Log("Unity: ATSplashAdWrapper::showAutoSplashAd(" + placementID + ")"); + ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "showAutoSplashAd:extraJsonString:", new object[]{placementID, mapJson}); + } + + + +} + + + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATSplashAdWrapper.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATSplashAdWrapper.cs.meta new file mode 100644 index 0000000..7dcf242 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATSplashAdWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9a6d70449055d4948ab0a895f51ce6f0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATUnityCBridge.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATUnityCBridge.cs new file mode 100644 index 0000000..89cf23f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATUnityCBridge.cs @@ -0,0 +1,103 @@ +using System.Runtime.InteropServices; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using AOT; +using AnyThinkAds.ThirdParty.LitJson; +using System; + +public class ATUnityCBridge { + public delegate void CCallBack(string wrapperClass, string msg); + + #if UNITY_IOS || UNITY_IPHONE + [DllImport("__Internal")] + extern static bool at_message_from_unity(string msg, CCallBack callback); + + [DllImport("__Internal")] + extern static int at_get_message_for_unity(string msg, CCallBack callback); + + [DllImport("__Internal")] + extern static string at_get_string_message_for_unity(string msg, CCallBack callback); + #endif + + [MonoPInvokeCallback(typeof(CCallBack))] + static public void MessageFromC(string wrapperClass, string msg) { + Debug.Log("Unity: ATUnityCBridge::MessageFromC(" + wrapperClass + "," + msg + ")"); + JsonData jsonData = JsonMapper.ToObject(msg); + if (wrapperClass.Equals("ATRewardedVideoWrapper")) { + Debug.Log("Unity: ATUnityCBridge::MessageFromC(), hit rv"); + ATRewardedVideoWrapper.InvokeCallback(jsonData); + } else if (wrapperClass.Equals("ATNativeAdWrapper")) { + ATNativeAdWrapper.InvokeCallback(jsonData); + } else if (wrapperClass.Equals("ATInterstitialAdWrapper")) { + ATInterstitialAdWrapper.InvokeCallback(jsonData); + } else if (wrapperClass.Equals("ATBannerAdWrapper")) { + ATBannerAdWrapper.InvokeCallback(jsonData); + } else if (wrapperClass.Equals("ATNativeBannerAdWrapper")) { + ATNativeBannerAdWrapper.InvokeCallback(jsonData); + } else if (wrapperClass.Equals("ATSplashAdWrapper")) { + ATSplashAdWrapper.InvokeCallback(jsonData); + } + } + + static public bool SendMessageToC(string className, string selector, object[] arguments) { + return SendMessageToC(className, selector, arguments, false); + } + + static public int GetMessageFromC(string className, string selector, object[] arguments) { + Debug.Log("Unity: ATUnityCBridge::GetMessageFromC()"); + Dictionary msgDict = new Dictionary(); + msgDict.Add("class", className); + msgDict.Add("selector", selector); + msgDict.Add("arguments", arguments); + #if UNITY_IOS || UNITY_IPHONE + return at_get_message_for_unity(JsonMapper.ToJson(msgDict), null); + #else + return 0; + #endif + } + + static public string GetStringMessageFromC(string className, string selector, object[] arguments) { + Debug.Log("Unity: ATUnityCBridge::GetStringMessageFromC()"); + Dictionary msgDict = new Dictionary(); + msgDict.Add("class", className); + msgDict.Add("selector", selector); + msgDict.Add("arguments", arguments); + #if UNITY_IOS || UNITY_IPHONE + return at_get_string_message_for_unity(JsonMapper.ToJson(msgDict), null); + #else + return ""; + #endif + } + + static public bool SendMessageToC(string className, string selector, object[] arguments, bool carryCallback) { + Debug.Log("Unity: ATUnityCBridge::SendMessageToC()"); + Dictionary msgDict = new Dictionary(); + msgDict.Add("class", className); + msgDict.Add("selector", selector); + msgDict.Add("arguments", arguments); + CCallBack callback = null; + if (carryCallback) callback = MessageFromC; + #if UNITY_IOS || UNITY_IPHONE + return at_message_from_unity(JsonMapper.ToJson(msgDict), callback); + #else + return false; + #endif + } + +#if UNITY_IOS || UNITY_IPHONE + [DllImport("__Internal")] + extern static bool at_message_from_unity(string msg, Func callback); +#endif + static public void SendMessageToCWithCallBack(string className, string selector, object[] arguments, Func callback) + { + Debug.Log("Unity: ATUnityCBridge::SendMessageToCWithCallBack()"); + Dictionary msgDict = new Dictionary(); + msgDict.Add("class", className); + msgDict.Add("selector", selector); + msgDict.Add("arguments", arguments); +#if UNITY_IOS || UNITY_IPHONE + at_message_from_unity(JsonMapper.ToJson(msgDict), callback); +#endif + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATUnityCBridge.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATUnityCBridge.cs.meta new file mode 100644 index 0000000..8a4a42c --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Platform/iOS/Internal/Script/ATUnityCBridge.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4eff27095fb1c4ea696177bd0f62415e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins.meta new file mode 100644 index 0000000..470f32f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 81f957c287adb41d69f515d5b0938f4c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android.meta new file mode 100644 index 0000000..3578f3a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7a46fd55c2e5340c08a24da48235bcd0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina.meta new file mode 100644 index 0000000..c776b5f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 96465535bcdc048b88816086ca093db4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/Editor.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/Editor.meta new file mode 100644 index 0000000..d469592 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9ebcf18be13024d0d9cd589bb1960161 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/Editor/Dependencies.xml b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/Editor/Dependencies.xml new file mode 100644 index 0000000..f995da5 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/Editor/Dependencies.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/Editor/Dependencies.xml.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/Editor/Dependencies.xml.meta new file mode 100644 index 0000000..91d0e2a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/Editor/Dependencies.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a883746bcee5944b8bc46759801d2705 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation.meta new file mode 100644 index 0000000..292d89a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7ede8d186fd294b42a684deb1567e698 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob.meta new file mode 100644 index 0000000..38f68b2 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 055379aa53d2e4c82a517eb079e3f27e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/Editor.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/Editor.meta new file mode 100644 index 0000000..41dae5d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2c92d1a481aa444caad03a1d28a5001e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/Editor/Dependencies.xml b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/Editor/Dependencies.xml new file mode 100644 index 0000000..ffdbfdc --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/Editor/Dependencies.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/network_data.json b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/network_data.json new file mode 100644 index 0000000..4c60708 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/network_data.json @@ -0,0 +1 @@ +{"name":"admob","version":"24.4.0","country":2,"path":"Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob"} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/network_data.json.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/network_data.json.meta new file mode 100644 index 0000000..62caf2d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/network_data.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 761f1ff3980f84e49900a4236f781860 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/thinkup_network_unity_admob.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/thinkup_network_unity_admob.aar new file mode 100644 index 0000000..514c6a6 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/thinkup_network_unity_admob.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/thinkup_network_unity_admob.aar.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/thinkup_network_unity_admob.aar.meta new file mode 100644 index 0000000..9030879 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/thinkup_network_unity_admob.aar.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 2abf163e8fe024a728b48f3b90f8888f +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin.meta new file mode 100644 index 0000000..9ab0e45 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 61ee46207e03b48a69a0c06c6def8632 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/Editor.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/Editor.meta new file mode 100644 index 0000000..4ea5dd7 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 05623daf0cd9047ecac8955bee34121e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/Editor/Dependencies.xml b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/Editor/Dependencies.xml new file mode 100644 index 0000000..80d48c7 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/Editor/Dependencies.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/network_data.json b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/network_data.json new file mode 100644 index 0000000..3cfc7dc --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/network_data.json @@ -0,0 +1 @@ +{"name":"applovin","version":"13.3.1","country":2,"path":"Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin"} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/network_data.json.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/network_data.json.meta new file mode 100644 index 0000000..f1c8349 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/network_data.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a482d7d2170b349329fd38a2b62385ae +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/thinkup_network_unity_applovin.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/thinkup_network_unity_applovin.aar new file mode 100644 index 0000000..27f0998 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/thinkup_network_unity_applovin.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/thinkup_network_unity_applovin.aar.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/thinkup_network_unity_applovin.aar.meta new file mode 100644 index 0000000..39ac140 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/thinkup_network_unity_applovin.aar.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 9a9b1cde5b02541eba2f6dca6dda6c6e +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo.meta new file mode 100644 index 0000000..8621c55 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8da2d186f805e44db848f121395f957c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/Editor.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/Editor.meta new file mode 100644 index 0000000..4030dc3 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 229226e76dca947ca940c0621b990a3c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/Editor/Dependencies.xml b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/Editor/Dependencies.xml new file mode 100644 index 0000000..fd77232 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/Editor/Dependencies.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/network_data.json b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/network_data.json new file mode 100644 index 0000000..803c744 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/network_data.json @@ -0,0 +1 @@ +{"name":"bigo","version":"5.3.0","country":2,"path":"Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo"} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/network_data.json.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/network_data.json.meta new file mode 100644 index 0000000..b179e7b --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/network_data.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 3f723658939774a0b9d52c49edc7ec3e +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/thinkup_network_unity_bigo.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/thinkup_network_unity_bigo.aar new file mode 100644 index 0000000..9ffde43 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/thinkup_network_unity_bigo.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/thinkup_network_unity_bigo.aar.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/thinkup_network_unity_bigo.aar.meta new file mode 100644 index 0000000..0e0f45a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/thinkup_network_unity_bigo.aar.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: fca6da1a7b2614cb5b559b62fc97d417 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber.meta new file mode 100644 index 0000000..31351bd --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9db588bd9cb52440098bb0e1c28af839 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/Editor.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/Editor.meta new file mode 100644 index 0000000..43abf79 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7df39d48384644559a2ba421d6cda087 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/Editor/Dependencies.xml b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/Editor/Dependencies.xml new file mode 100644 index 0000000..c8a91d0 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/Editor/Dependencies.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/network_data.json b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/network_data.json new file mode 100644 index 0000000..d3d553c --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/network_data.json @@ -0,0 +1 @@ +{"name":"fyber","version":"8.3.7","country":2,"path":"Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber"} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/network_data.json.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/network_data.json.meta new file mode 100644 index 0000000..8fc7ca0 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/network_data.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6aac52d2f4daf4f6a8a51e7c7a2572ff +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/thinkup_network_unity_fyber.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/thinkup_network_unity_fyber.aar new file mode 100644 index 0000000..bb1d8b4 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/thinkup_network_unity_fyber.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/thinkup_network_unity_fyber.aar.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/thinkup_network_unity_fyber.aar.meta new file mode 100644 index 0000000..b3f9470 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/thinkup_network_unity_fyber.aar.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 1c70cfbd0bcd1447ba7d948988f15f71 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm.meta new file mode 100644 index 0000000..e48ea6b --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 662423f3d90c849fcabcba32892f63a2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/Editor.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/Editor.meta new file mode 100644 index 0000000..cc3e1e9 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bb739f25462684727bb977753ddbebbe +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/Editor/Dependencies.xml b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/Editor/Dependencies.xml new file mode 100644 index 0000000..ff176ef --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/Editor/Dependencies.xml @@ -0,0 +1,9 @@ + + + + https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea + + + + + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/network_data.json b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/network_data.json new file mode 100644 index 0000000..0b1b618 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/network_data.json @@ -0,0 +1 @@ +{"name":"gtm","version":"16.9.71","country":2,"path":"Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm"} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/network_data.json.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/network_data.json.meta new file mode 100644 index 0000000..6f1420f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/network_data.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6edf4da90c7f14331a81b4ff1a2e33fa +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/thinkup_network_unity_gtm.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/thinkup_network_unity_gtm.aar new file mode 100644 index 0000000..b4c4b54 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/thinkup_network_unity_gtm.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/thinkup_network_unity_gtm.aar.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/thinkup_network_unity_gtm.aar.meta new file mode 100644 index 0000000..bab2c43 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/thinkup_network_unity_gtm.aar.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 8296858ad76404059bbff4173020daed +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai.meta new file mode 100644 index 0000000..a1ba923 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 066d0831e97104752819ff4ae5ad3f0f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/Editor.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/Editor.meta new file mode 100644 index 0000000..5d3233d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c6799b23c0c7346a186262f804a06708 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/Editor/Dependencies.xml b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/Editor/Dependencies.xml new file mode 100644 index 0000000..8575189 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/Editor/Dependencies.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/network_data.json b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/network_data.json new file mode 100644 index 0000000..19685a0 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/network_data.json @@ -0,0 +1 @@ +{"name":"kwai","version":"1.2.15","country":2,"path":"Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai"} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/network_data.json.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/network_data.json.meta new file mode 100644 index 0000000..0dd24de --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/network_data.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0ce3d9cb75b894cab888021ce563a9cf +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/thinkup_network_unity_kwai.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/thinkup_network_unity_kwai.aar new file mode 100644 index 0000000..627a6df Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/thinkup_network_unity_kwai.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/thinkup_network_unity_kwai.aar.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/thinkup_network_unity_kwai.aar.meta new file mode 100644 index 0000000..675502a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/thinkup_network_unity_kwai.aar.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 5497e10c383054c21a540706223aafaa +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle.meta new file mode 100644 index 0000000..31eaa99 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f0343d537e2f146a082d2681d1ab1731 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/Editor.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/Editor.meta new file mode 100644 index 0000000..7fc2a8f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a6887ea556e784691b5d9980e84f8bfe +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/Editor/Dependencies.xml b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/Editor/Dependencies.xml new file mode 100644 index 0000000..7144a5a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/Editor/Dependencies.xml @@ -0,0 +1,9 @@ + + + + https://artifact.bytedance.com/repository/pangle + + + + + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/network_data.json b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/network_data.json new file mode 100644 index 0000000..592e9ac --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/network_data.json @@ -0,0 +1 @@ +{"name":"pangle","version":"7.2.0.6","country":2,"path":"Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle"} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/network_data.json.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/network_data.json.meta new file mode 100644 index 0000000..6bf7e7b --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/network_data.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5e2dbcd98b64e419197e45319e4d9b2c +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/thinkup_network_unity_pangle.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/thinkup_network_unity_pangle.aar new file mode 100644 index 0000000..ba1675a Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/thinkup_network_unity_pangle.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/thinkup_network_unity_pangle.aar.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/thinkup_network_unity_pangle.aar.meta new file mode 100644 index 0000000..47af768 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/thinkup_network_unity_pangle.aar.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 11d4c0ec450ef4944ab6905e4ef563d5 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads.meta new file mode 100644 index 0000000..53ff5f5 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b7b0eb7088dd84ce79046c23c4b34470 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/Editor.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/Editor.meta new file mode 100644 index 0000000..eea3c43 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6f4db75af6707471aa2716c519cf19e2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/Editor/Dependencies.xml b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/Editor/Dependencies.xml new file mode 100644 index 0000000..803e83f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/Editor/Dependencies.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/network_data.json b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/network_data.json new file mode 100644 index 0000000..0130ba5 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/network_data.json @@ -0,0 +1 @@ +{"name":"unityads","version":"4.14.0","country":2,"path":"Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads"} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/network_data.json.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/network_data.json.meta new file mode 100644 index 0000000..489f6a5 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/network_data.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a0d4cd89ecb5a45389c92a794a173b38 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/thinkup_network_unity_unityads.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/thinkup_network_unity_unityads.aar new file mode 100644 index 0000000..6d5e654 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/thinkup_network_unity_unityads.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/thinkup_network_unity_unityads.aar.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/thinkup_network_unity_unityads.aar.meta new file mode 100644 index 0000000..623088a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/thinkup_network_unity_unityads.aar.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 267bf037959874d0bbd7fdaab30006fe +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle.meta new file mode 100644 index 0000000..b164295 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4d2ff92df79d498ab5acd7c17d6f4a1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/Editor.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/Editor.meta new file mode 100644 index 0000000..5d4ef8a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fb3605b7ee9ae474b87fb908d1006539 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/Editor/Dependencies.xml b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/Editor/Dependencies.xml new file mode 100644 index 0000000..f9c16da --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/Editor/Dependencies.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/network_data.json b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/network_data.json new file mode 100644 index 0000000..d87d22e --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/network_data.json @@ -0,0 +1 @@ +{"name":"vungle","version":"7.5.0","country":2,"path":"Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle"} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/network_data.json.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/network_data.json.meta new file mode 100644 index 0000000..57757ca --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/network_data.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ec650f3b27f664185b3fdc115d73f8cc +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/thinkup_network_unity_vungle.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/thinkup_network_unity_vungle.aar new file mode 100644 index 0000000..7a644f0 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/thinkup_network_unity_vungle.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/thinkup_network_unity_vungle.aar.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/thinkup_network_unity_vungle.aar.meta new file mode 100644 index 0000000..129c1a2 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/thinkup_network_unity_vungle.aar.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 0c7b31f3c0b3b4f8eb5ed64734518bb9 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base.meta new file mode 100644 index 0000000..2272e96 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a9a8aa2e2dbea4b4a813050c2f98f355 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_banner.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_banner.aar new file mode 100644 index 0000000..4015f03 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_banner.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_core.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_core.aar new file mode 100644 index 0000000..42fcd17 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_core.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_interstitial.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_interstitial.aar new file mode 100644 index 0000000..d16c099 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_interstitial.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_mediavideo.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_mediavideo.aar new file mode 100644 index 0000000..3e5f8e8 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_mediavideo.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_native.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_native.aar new file mode 100644 index 0000000..056e280 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_native.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_rewardvideo.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_rewardvideo.aar new file mode 100644 index 0000000..9b8b6da Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_rewardvideo.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_splash.aar b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_splash.aar new file mode 100644 index 0000000..e99bcd4 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/thinkup_base/thinkup_splash.aar differ diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid.meta new file mode 100644 index 0000000..245a55d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bebf6a87e40e64e0592abca3a5b93fef +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/IJsonWrapper.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/IJsonWrapper.cs new file mode 100644 index 0000000..6956510 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/IJsonWrapper.cs @@ -0,0 +1,60 @@ +#region Header +/** + * IJsonWrapper.cs + * Interface that represents a type capable of handling all kinds of JSON + * data. This is mainly used when mapping objects through JsonMapper, and + * it's implemented by JsonData. + * + * The authors disclaim copyright to this source code. For more details, see + * the COPYING file included with this distribution. + **/ +#endregion + + +using System.Collections; +using System.Collections.Specialized; + + +namespace AnyThinkAds.ThirdParty.LitJson +{ + public enum JsonType + { + None, + + Object, + Array, + String, + Int, + Long, + Double, + Boolean + } + + public interface IJsonWrapper : IList, IOrderedDictionary + { + bool IsArray { get; } + bool IsBoolean { get; } + bool IsDouble { get; } + bool IsInt { get; } + bool IsLong { get; } + bool IsObject { get; } + bool IsString { get; } + + bool GetBoolean (); + double GetDouble (); + int GetInt (); + JsonType GetJsonType (); + long GetLong (); + string GetString (); + + void SetBoolean (bool val); + void SetDouble (double val); + void SetInt (int val); + void SetJsonType (JsonType type); + void SetLong (long val); + void SetString (string val); + + string ToJson (); + void ToJson (JsonWriter writer); + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/IJsonWrapper.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/IJsonWrapper.cs.meta new file mode 100644 index 0000000..6f624ca --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/IJsonWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 724fd6c8112d84b9dac512dbcf21df16 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonData.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonData.cs new file mode 100644 index 0000000..8205150 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonData.cs @@ -0,0 +1,1059 @@ +#region Header +/** + * JsonData.cs + * Generic type to hold JSON data (objects, arrays, and so on). This is + * the default type returned by JsonMapper.ToObject(). + * + * The authors disclaim copyright to this source code. For more details, see + * the COPYING file included with this distribution. + **/ +#endregion + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.IO; + + +namespace AnyThinkAds.ThirdParty.LitJson +{ + public class JsonData : IJsonWrapper, IEquatable + { + #region Fields + private IList inst_array; + private bool inst_boolean; + private double inst_double; + private int inst_int; + private long inst_long; + private IDictionary inst_object; + private string inst_string; + private string json; + private JsonType type; + + // Used to implement the IOrderedDictionary interface + private IList> object_list; + #endregion + + + #region Properties + public int Count { + get { return EnsureCollection ().Count; } + } + + public bool IsArray { + get { return type == JsonType.Array; } + } + + public bool IsBoolean { + get { return type == JsonType.Boolean; } + } + + public bool IsDouble { + get { return type == JsonType.Double; } + } + + public bool IsInt { + get { return type == JsonType.Int; } + } + + public bool IsLong { + get { return type == JsonType.Long; } + } + + public bool IsObject { + get { return type == JsonType.Object; } + } + + public bool IsString { + get { return type == JsonType.String; } + } + + public ICollection Keys { + get { EnsureDictionary (); return inst_object.Keys; } + } + + /// + /// Determines whether the json contains an element that has the specified key. + /// + /// The key to locate in the json. + /// true if the json contains an element that has the specified key; otherwise, false. + public Boolean ContainsKey(String key) { + EnsureDictionary(); + return this.inst_object.Keys.Contains(key); + } + #endregion + + + #region ICollection Properties + int ICollection.Count { + get { + return Count; + } + } + + bool ICollection.IsSynchronized { + get { + return EnsureCollection ().IsSynchronized; + } + } + + object ICollection.SyncRoot { + get { + return EnsureCollection ().SyncRoot; + } + } + #endregion + + + #region IDictionary Properties + bool IDictionary.IsFixedSize { + get { + return EnsureDictionary ().IsFixedSize; + } + } + + bool IDictionary.IsReadOnly { + get { + return EnsureDictionary ().IsReadOnly; + } + } + + ICollection IDictionary.Keys { + get { + EnsureDictionary (); + IList keys = new List (); + + foreach (KeyValuePair entry in + object_list) { + keys.Add (entry.Key); + } + + return (ICollection) keys; + } + } + + ICollection IDictionary.Values { + get { + EnsureDictionary (); + IList values = new List (); + + foreach (KeyValuePair entry in + object_list) { + values.Add (entry.Value); + } + + return (ICollection) values; + } + } + #endregion + + + + #region IJsonWrapper Properties + bool IJsonWrapper.IsArray { + get { return IsArray; } + } + + bool IJsonWrapper.IsBoolean { + get { return IsBoolean; } + } + + bool IJsonWrapper.IsDouble { + get { return IsDouble; } + } + + bool IJsonWrapper.IsInt { + get { return IsInt; } + } + + bool IJsonWrapper.IsLong { + get { return IsLong; } + } + + bool IJsonWrapper.IsObject { + get { return IsObject; } + } + + bool IJsonWrapper.IsString { + get { return IsString; } + } + #endregion + + + #region IList Properties + bool IList.IsFixedSize { + get { + return EnsureList ().IsFixedSize; + } + } + + bool IList.IsReadOnly { + get { + return EnsureList ().IsReadOnly; + } + } + #endregion + + + #region IDictionary Indexer + object IDictionary.this[object key] { + get { + return EnsureDictionary ()[key]; + } + + set { + if (! (key is String)) + throw new ArgumentException ( + "The key has to be a string"); + + JsonData data = ToJsonData (value); + + this[(string) key] = data; + } + } + #endregion + + + #region IOrderedDictionary Indexer + object IOrderedDictionary.this[int idx] { + get { + EnsureDictionary (); + return object_list[idx].Value; + } + + set { + EnsureDictionary (); + JsonData data = ToJsonData (value); + + KeyValuePair old_entry = object_list[idx]; + + inst_object[old_entry.Key] = data; + + KeyValuePair entry = + new KeyValuePair (old_entry.Key, data); + + object_list[idx] = entry; + } + } + #endregion + + + #region IList Indexer + object IList.this[int index] { + get { + return EnsureList ()[index]; + } + + set { + EnsureList (); + JsonData data = ToJsonData (value); + + this[index] = data; + } + } + #endregion + + + #region Public Indexers + public JsonData this[string prop_name] { + get { + EnsureDictionary (); + return inst_object[prop_name]; + } + + set { + EnsureDictionary (); + + KeyValuePair entry = + new KeyValuePair (prop_name, value); + + if (inst_object.ContainsKey (prop_name)) { + for (int i = 0; i < object_list.Count; i++) { + if (object_list[i].Key == prop_name) { + object_list[i] = entry; + break; + } + } + } else + object_list.Add (entry); + + inst_object[prop_name] = value; + + json = null; + } + } + + public JsonData this[int index] { + get { + EnsureCollection (); + + if (type == JsonType.Array) + return inst_array[index]; + + return object_list[index].Value; + } + + set { + EnsureCollection (); + + if (type == JsonType.Array) + inst_array[index] = value; + else { + KeyValuePair entry = object_list[index]; + KeyValuePair new_entry = + new KeyValuePair (entry.Key, value); + + object_list[index] = new_entry; + inst_object[entry.Key] = value; + } + + json = null; + } + } + #endregion + + + #region Constructors + public JsonData () + { + } + + public JsonData (bool boolean) + { + type = JsonType.Boolean; + inst_boolean = boolean; + } + + public JsonData (double number) + { + type = JsonType.Double; + inst_double = number; + } + + public JsonData (int number) + { + type = JsonType.Int; + inst_int = number; + } + + public JsonData (long number) + { + type = JsonType.Long; + inst_long = number; + } + + public JsonData (object obj) + { + if (obj is Boolean) { + type = JsonType.Boolean; + inst_boolean = (bool) obj; + return; + } + + if (obj is Double) { + type = JsonType.Double; + inst_double = (double) obj; + return; + } + + if (obj is Int32) { + type = JsonType.Int; + inst_int = (int) obj; + return; + } + + if (obj is Int64) { + type = JsonType.Long; + inst_long = (long) obj; + return; + } + + if (obj is String) { + type = JsonType.String; + inst_string = (string) obj; + return; + } + + throw new ArgumentException ( + "Unable to wrap the given object with JsonData"); + } + + public JsonData (string str) + { + type = JsonType.String; + inst_string = str; + } + #endregion + + + #region Implicit Conversions + public static implicit operator JsonData (Boolean data) + { + return new JsonData (data); + } + + public static implicit operator JsonData (Double data) + { + return new JsonData (data); + } + + public static implicit operator JsonData (Int32 data) + { + return new JsonData (data); + } + + public static implicit operator JsonData (Int64 data) + { + return new JsonData (data); + } + + public static implicit operator JsonData (String data) + { + return new JsonData (data); + } + #endregion + + + #region Explicit Conversions + public static explicit operator Boolean (JsonData data) + { + if (data.type != JsonType.Boolean) + throw new InvalidCastException ( + "Instance of JsonData doesn't hold a double"); + + return data.inst_boolean; + } + + public static explicit operator Double (JsonData data) + { + if (data.type != JsonType.Double) + throw new InvalidCastException ( + "Instance of JsonData doesn't hold a double"); + + return data.inst_double; + } + + public static explicit operator Int32(JsonData data) + { + if (data.type != JsonType.Int && data.type != JsonType.Long) + { + throw new InvalidCastException( + "Instance of JsonData doesn't hold an int"); + } + + // cast may truncate data... but that's up to the user to consider + return data.type == JsonType.Int ? data.inst_int : (int)data.inst_long; + } + + public static explicit operator Int64(JsonData data) + { + if (data.type != JsonType.Long && data.type != JsonType.Int) + { + throw new InvalidCastException( + "Instance of JsonData doesn't hold a long"); + } + + return data.type == JsonType.Long ? data.inst_long : data.inst_int; + } + + public static explicit operator String (JsonData data) + { + if (data.type != JsonType.String) + throw new InvalidCastException ( + "Instance of JsonData doesn't hold a string"); + + return data.inst_string; + } + #endregion + + + #region ICollection Methods + void ICollection.CopyTo (Array array, int index) + { + EnsureCollection ().CopyTo (array, index); + } + #endregion + + + #region IDictionary Methods + void IDictionary.Add (object key, object value) + { + JsonData data = ToJsonData (value); + + EnsureDictionary ().Add (key, data); + + KeyValuePair entry = + new KeyValuePair ((string) key, data); + object_list.Add (entry); + + json = null; + } + + void IDictionary.Clear () + { + EnsureDictionary ().Clear (); + object_list.Clear (); + json = null; + } + + bool IDictionary.Contains (object key) + { + return EnsureDictionary ().Contains (key); + } + + IDictionaryEnumerator IDictionary.GetEnumerator () + { + return ((IOrderedDictionary) this).GetEnumerator (); + } + + void IDictionary.Remove (object key) + { + EnsureDictionary ().Remove (key); + + for (int i = 0; i < object_list.Count; i++) { + if (object_list[i].Key == (string) key) { + object_list.RemoveAt (i); + break; + } + } + + json = null; + } + #endregion + + + #region IEnumerable Methods + IEnumerator IEnumerable.GetEnumerator () + { + return EnsureCollection ().GetEnumerator (); + } + #endregion + + + #region IJsonWrapper Methods + bool IJsonWrapper.GetBoolean () + { + if (type != JsonType.Boolean) + throw new InvalidOperationException ( + "JsonData instance doesn't hold a boolean"); + + return inst_boolean; + } + + double IJsonWrapper.GetDouble () + { + if (type != JsonType.Double) + throw new InvalidOperationException ( + "JsonData instance doesn't hold a double"); + + return inst_double; + } + + int IJsonWrapper.GetInt () + { + if (type != JsonType.Int) + throw new InvalidOperationException ( + "JsonData instance doesn't hold an int"); + + return inst_int; + } + + long IJsonWrapper.GetLong () + { + if (type != JsonType.Long) + throw new InvalidOperationException ( + "JsonData instance doesn't hold a long"); + + return inst_long; + } + + string IJsonWrapper.GetString () + { + if (type != JsonType.String) + throw new InvalidOperationException ( + "JsonData instance doesn't hold a string"); + + return inst_string; + } + + void IJsonWrapper.SetBoolean (bool val) + { + type = JsonType.Boolean; + inst_boolean = val; + json = null; + } + + void IJsonWrapper.SetDouble (double val) + { + type = JsonType.Double; + inst_double = val; + json = null; + } + + void IJsonWrapper.SetInt (int val) + { + type = JsonType.Int; + inst_int = val; + json = null; + } + + void IJsonWrapper.SetLong (long val) + { + type = JsonType.Long; + inst_long = val; + json = null; + } + + void IJsonWrapper.SetString (string val) + { + type = JsonType.String; + inst_string = val; + json = null; + } + + string IJsonWrapper.ToJson () + { + return ToJson (); + } + + void IJsonWrapper.ToJson (JsonWriter writer) + { + ToJson (writer); + } + #endregion + + + #region IList Methods + int IList.Add (object value) + { + return Add (value); + } + + void IList.Clear () + { + EnsureList ().Clear (); + json = null; + } + + bool IList.Contains (object value) + { + return EnsureList ().Contains (value); + } + + int IList.IndexOf (object value) + { + return EnsureList ().IndexOf (value); + } + + void IList.Insert (int index, object value) + { + EnsureList ().Insert (index, value); + json = null; + } + + void IList.Remove (object value) + { + EnsureList ().Remove (value); + json = null; + } + + void IList.RemoveAt (int index) + { + EnsureList ().RemoveAt (index); + json = null; + } + #endregion + + + #region IOrderedDictionary Methods + IDictionaryEnumerator IOrderedDictionary.GetEnumerator () + { + EnsureDictionary (); + + return new OrderedDictionaryEnumerator ( + object_list.GetEnumerator ()); + } + + void IOrderedDictionary.Insert (int idx, object key, object value) + { + string property = (string) key; + JsonData data = ToJsonData (value); + + this[property] = data; + + KeyValuePair entry = + new KeyValuePair (property, data); + + object_list.Insert (idx, entry); + } + + void IOrderedDictionary.RemoveAt (int idx) + { + EnsureDictionary (); + + inst_object.Remove (object_list[idx].Key); + object_list.RemoveAt (idx); + } + #endregion + + + #region Private Methods + private ICollection EnsureCollection () + { + if (type == JsonType.Array) + return (ICollection) inst_array; + + if (type == JsonType.Object) + return (ICollection) inst_object; + + throw new InvalidOperationException ( + "The JsonData instance has to be initialized first"); + } + + private IDictionary EnsureDictionary () + { + if (type == JsonType.Object) + return (IDictionary) inst_object; + + if (type != JsonType.None) + throw new InvalidOperationException ( + "Instance of JsonData is not a dictionary"); + + type = JsonType.Object; + inst_object = new Dictionary (); + object_list = new List> (); + + return (IDictionary) inst_object; + } + + private IList EnsureList () + { + if (type == JsonType.Array) + return (IList) inst_array; + + if (type != JsonType.None) + throw new InvalidOperationException ( + "Instance of JsonData is not a list"); + + type = JsonType.Array; + inst_array = new List (); + + return (IList) inst_array; + } + + private JsonData ToJsonData (object obj) + { + if (obj == null) + return null; + + if (obj is JsonData) + return (JsonData) obj; + + return new JsonData (obj); + } + + private static void WriteJson (IJsonWrapper obj, JsonWriter writer) + { + if (obj == null) { + writer.Write (null); + return; + } + + if (obj.IsString) { + writer.Write (obj.GetString ()); + return; + } + + if (obj.IsBoolean) { + writer.Write (obj.GetBoolean ()); + return; + } + + if (obj.IsDouble) { + writer.Write (obj.GetDouble ()); + return; + } + + if (obj.IsInt) { + writer.Write (obj.GetInt ()); + return; + } + + if (obj.IsLong) { + writer.Write (obj.GetLong ()); + return; + } + + if (obj.IsArray) { + writer.WriteArrayStart (); + foreach (object elem in (IList) obj) + WriteJson ((JsonData) elem, writer); + writer.WriteArrayEnd (); + + return; + } + + if (obj.IsObject) { + writer.WriteObjectStart (); + + foreach (DictionaryEntry entry in ((IDictionary) obj)) { + writer.WritePropertyName ((string) entry.Key); + WriteJson ((JsonData) entry.Value, writer); + } + writer.WriteObjectEnd (); + + return; + } + } + #endregion + + + public int Add (object value) + { + JsonData data = ToJsonData (value); + + json = null; + + return EnsureList ().Add (data); + } + + public bool Remove(object obj) + { + json = null; + if(IsObject) + { + JsonData value = null; + if (inst_object.TryGetValue((string)obj, out value)) + return inst_object.Remove((string)obj) && object_list.Remove(new KeyValuePair((string)obj, value)); + else + throw new KeyNotFoundException("The specified key was not found in the JsonData object."); + } + if(IsArray) + { + return inst_array.Remove(ToJsonData(obj)); + } + throw new InvalidOperationException ( + "Instance of JsonData is not an object or a list."); + } + + public void Clear () + { + if (IsObject) { + ((IDictionary) this).Clear (); + return; + } + + if (IsArray) { + ((IList) this).Clear (); + return; + } + } + + public bool Equals (JsonData x) + { + if (x == null) + return false; + + if (x.type != this.type) + { + // further check to see if this is a long to int comparison + if ((x.type != JsonType.Int && x.type != JsonType.Long) + || (this.type != JsonType.Int && this.type != JsonType.Long)) + { + return false; + } + } + + switch (this.type) { + case JsonType.None: + return true; + + case JsonType.Object: + return this.inst_object.Equals (x.inst_object); + + case JsonType.Array: + return this.inst_array.Equals (x.inst_array); + + case JsonType.String: + return this.inst_string.Equals (x.inst_string); + + case JsonType.Int: + { + if (x.IsLong) + { + if (x.inst_long < Int32.MinValue || x.inst_long > Int32.MaxValue) + return false; + return this.inst_int.Equals((int)x.inst_long); + } + return this.inst_int.Equals(x.inst_int); + } + + case JsonType.Long: + { + if (x.IsInt) + { + if (this.inst_long < Int32.MinValue || this.inst_long > Int32.MaxValue) + return false; + return x.inst_int.Equals((int)this.inst_long); + } + return this.inst_long.Equals(x.inst_long); + } + + case JsonType.Double: + return this.inst_double.Equals (x.inst_double); + + case JsonType.Boolean: + return this.inst_boolean.Equals (x.inst_boolean); + } + + return false; + } + + public JsonType GetJsonType () + { + return type; + } + + public void SetJsonType (JsonType type) + { + if (this.type == type) + return; + + switch (type) { + case JsonType.None: + break; + + case JsonType.Object: + inst_object = new Dictionary (); + object_list = new List> (); + break; + + case JsonType.Array: + inst_array = new List (); + break; + + case JsonType.String: + inst_string = default (String); + break; + + case JsonType.Int: + inst_int = default (Int32); + break; + + case JsonType.Long: + inst_long = default (Int64); + break; + + case JsonType.Double: + inst_double = default (Double); + break; + + case JsonType.Boolean: + inst_boolean = default (Boolean); + break; + } + + this.type = type; + } + + public string ToJson () + { + if (json != null) + return json; + + StringWriter sw = new StringWriter (); + JsonWriter writer = new JsonWriter (sw); + writer.Validate = false; + + WriteJson (this, writer); + json = sw.ToString (); + + return json; + } + + public void ToJson (JsonWriter writer) + { + bool old_validate = writer.Validate; + + writer.Validate = false; + + WriteJson (this, writer); + + writer.Validate = old_validate; + } + + public override string ToString () + { + switch (type) { + case JsonType.Array: + return "JsonData array"; + + case JsonType.Boolean: + return inst_boolean.ToString (); + + case JsonType.Double: + return inst_double.ToString (); + + case JsonType.Int: + return inst_int.ToString (); + + case JsonType.Long: + return inst_long.ToString (); + + case JsonType.Object: + return "JsonData object"; + + case JsonType.String: + return inst_string; + } + + return "Uninitialized JsonData"; + } + } + + + internal class OrderedDictionaryEnumerator : IDictionaryEnumerator + { + IEnumerator> list_enumerator; + + + public object Current { + get { return Entry; } + } + + public DictionaryEntry Entry { + get { + KeyValuePair curr = list_enumerator.Current; + return new DictionaryEntry (curr.Key, curr.Value); + } + } + + public object Key { + get { return list_enumerator.Current.Key; } + } + + public object Value { + get { return list_enumerator.Current.Value; } + } + + + public OrderedDictionaryEnumerator ( + IEnumerator> enumerator) + { + list_enumerator = enumerator; + } + + + public bool MoveNext () + { + return list_enumerator.MoveNext (); + } + + public void Reset () + { + list_enumerator.Reset (); + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonData.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonData.cs.meta new file mode 100644 index 0000000..db7cf89 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 95f535fc348584b4996bd38a3aa53ab1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonException.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonException.cs new file mode 100644 index 0000000..3f88a0f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonException.cs @@ -0,0 +1,65 @@ +#region Header +/** + * JsonException.cs + * Base class throwed by LitJSON when a parsing error occurs. + * + * The authors disclaim copyright to this source code. For more details, see + * the COPYING file included with this distribution. + **/ +#endregion + + +using System; + + +namespace AnyThinkAds.ThirdParty.LitJson +{ + public class JsonException : +#if NETSTANDARD1_5 + Exception +#else + ApplicationException +#endif + { + public JsonException () : base () + { + } + + internal JsonException (ParserToken token) : + base (String.Format ( + "Invalid token '{0}' in input string", token)) + { + } + + internal JsonException (ParserToken token, + Exception inner_exception) : + base (String.Format ( + "Invalid token '{0}' in input string", token), + inner_exception) + { + } + + internal JsonException (int c) : + base (String.Format ( + "Invalid character '{0}' in input string", (char) c)) + { + } + + internal JsonException (int c, Exception inner_exception) : + base (String.Format ( + "Invalid character '{0}' in input string", (char) c), + inner_exception) + { + } + + + public JsonException (string message) : base (message) + { + } + + public JsonException (string message, Exception inner_exception) : + base (message, inner_exception) + { + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonException.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonException.cs.meta new file mode 100644 index 0000000..6b56baf --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonException.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 047fbd91a0fc349c0bc8c98db4324741 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonMapper.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonMapper.cs new file mode 100644 index 0000000..31a6541 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonMapper.cs @@ -0,0 +1,988 @@ +#region Header +/** + * JsonMapper.cs + * JSON to .Net object and object to JSON conversions. + * + * The authors disclaim copyright to this source code. For more details, see + * the COPYING file included with this distribution. + **/ +#endregion + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Reflection; + + +namespace AnyThinkAds.ThirdParty.LitJson +{ + internal struct PropertyMetadata + { + public MemberInfo Info; + public bool IsField; + public Type Type; + } + + + internal struct ArrayMetadata + { + private Type element_type; + private bool is_array; + private bool is_list; + + + public Type ElementType { + get { + if (element_type == null) + return typeof (JsonData); + + return element_type; + } + + set { element_type = value; } + } + + public bool IsArray { + get { return is_array; } + set { is_array = value; } + } + + public bool IsList { + get { return is_list; } + set { is_list = value; } + } + } + + + internal struct ObjectMetadata + { + private Type element_type; + private bool is_dictionary; + + private IDictionary properties; + + + public Type ElementType { + get { + if (element_type == null) + return typeof (JsonData); + + return element_type; + } + + set { element_type = value; } + } + + public bool IsDictionary { + get { return is_dictionary; } + set { is_dictionary = value; } + } + + public IDictionary Properties { + get { return properties; } + set { properties = value; } + } + } + + + internal delegate void ExporterFunc (object obj, JsonWriter writer); + public delegate void ExporterFunc (T obj, JsonWriter writer); + + internal delegate object ImporterFunc (object input); + public delegate TValue ImporterFunc (TJson input); + + public delegate IJsonWrapper WrapperFactory (); + + + public class JsonMapper + { + #region Fields + private static readonly int max_nesting_depth; + + private static readonly IFormatProvider datetime_format; + + private static readonly IDictionary base_exporters_table; + private static readonly IDictionary custom_exporters_table; + + private static readonly IDictionary> base_importers_table; + private static readonly IDictionary> custom_importers_table; + + private static readonly IDictionary array_metadata; + private static readonly object array_metadata_lock = new Object (); + + private static readonly IDictionary> conv_ops; + private static readonly object conv_ops_lock = new Object (); + + private static readonly IDictionary object_metadata; + private static readonly object object_metadata_lock = new Object (); + + private static readonly IDictionary> type_properties; + private static readonly object type_properties_lock = new Object (); + + private static readonly JsonWriter static_writer; + private static readonly object static_writer_lock = new Object (); + #endregion + + + #region Constructors + static JsonMapper () + { + max_nesting_depth = 100; + + array_metadata = new Dictionary (); + conv_ops = new Dictionary> (); + object_metadata = new Dictionary (); + type_properties = new Dictionary> (); + + static_writer = new JsonWriter (); + + datetime_format = DateTimeFormatInfo.InvariantInfo; + + base_exporters_table = new Dictionary (); + custom_exporters_table = new Dictionary (); + + base_importers_table = new Dictionary> (); + custom_importers_table = new Dictionary> (); + + RegisterBaseExporters (); + RegisterBaseImporters (); + } + #endregion + + + #region Private Methods + private static void AddArrayMetadata (Type type) + { + if (array_metadata.ContainsKey (type)) + return; + + ArrayMetadata data = new ArrayMetadata (); + + data.IsArray = type.IsArray; + + if (type.GetInterface ("System.Collections.IList") != null) + data.IsList = true; + + foreach (PropertyInfo p_info in type.GetProperties ()) { + if (p_info.Name != "Item") + continue; + + ParameterInfo[] parameters = p_info.GetIndexParameters (); + + if (parameters.Length != 1) + continue; + + if (parameters[0].ParameterType == typeof (int)) + data.ElementType = p_info.PropertyType; + } + + lock (array_metadata_lock) { + try { + array_metadata.Add (type, data); + } catch (ArgumentException) { + return; + } + } + } + + private static void AddObjectMetadata (Type type) + { + if (object_metadata.ContainsKey (type)) + return; + + ObjectMetadata data = new ObjectMetadata (); + + if (type.GetInterface ("System.Collections.IDictionary") != null) + data.IsDictionary = true; + + data.Properties = new Dictionary (); + + foreach (PropertyInfo p_info in type.GetProperties ()) { + if (p_info.Name == "Item") { + ParameterInfo[] parameters = p_info.GetIndexParameters (); + + if (parameters.Length != 1) + continue; + + if (parameters[0].ParameterType == typeof (string)) + data.ElementType = p_info.PropertyType; + + continue; + } + + PropertyMetadata p_data = new PropertyMetadata (); + p_data.Info = p_info; + p_data.Type = p_info.PropertyType; + + data.Properties.Add (p_info.Name, p_data); + } + + foreach (FieldInfo f_info in type.GetFields ()) { + PropertyMetadata p_data = new PropertyMetadata (); + p_data.Info = f_info; + p_data.IsField = true; + p_data.Type = f_info.FieldType; + + data.Properties.Add (f_info.Name, p_data); + } + + lock (object_metadata_lock) { + try { + object_metadata.Add (type, data); + } catch (ArgumentException) { + return; + } + } + } + + private static void AddTypeProperties (Type type) + { + if (type_properties.ContainsKey (type)) + return; + + IList props = new List (); + + foreach (PropertyInfo p_info in type.GetProperties ()) { + if (p_info.Name == "Item") + continue; + + PropertyMetadata p_data = new PropertyMetadata (); + p_data.Info = p_info; + p_data.IsField = false; + props.Add (p_data); + } + + foreach (FieldInfo f_info in type.GetFields ()) { + PropertyMetadata p_data = new PropertyMetadata (); + p_data.Info = f_info; + p_data.IsField = true; + + props.Add (p_data); + } + + lock (type_properties_lock) { + try { + type_properties.Add (type, props); + } catch (ArgumentException) { + return; + } + } + } + + private static MethodInfo GetConvOp (Type t1, Type t2) + { + lock (conv_ops_lock) { + if (! conv_ops.ContainsKey (t1)) + conv_ops.Add (t1, new Dictionary ()); + } + + if (conv_ops[t1].ContainsKey (t2)) + return conv_ops[t1][t2]; + + MethodInfo op = t1.GetMethod ( + "op_Implicit", new Type[] { t2 }); + + lock (conv_ops_lock) { + try { + conv_ops[t1].Add (t2, op); + } catch (ArgumentException) { + return conv_ops[t1][t2]; + } + } + + return op; + } + + private static object ReadValue (Type inst_type, JsonReader reader) + { + reader.Read (); + + if (reader.Token == JsonToken.ArrayEnd) + return null; + + Type underlying_type = Nullable.GetUnderlyingType(inst_type); + Type value_type = underlying_type ?? inst_type; + + if (reader.Token == JsonToken.Null) { + #if NETSTANDARD1_5 + if (inst_type.IsClass() || underlying_type != null) { + return null; + } + #else + if (inst_type.IsClass || underlying_type != null) { + return null; + } + #endif + + throw new JsonException (String.Format ( + "Can't assign null to an instance of type {0}", + inst_type)); + } + + if (reader.Token == JsonToken.Double || + reader.Token == JsonToken.Int || + reader.Token == JsonToken.Long || + reader.Token == JsonToken.String || + reader.Token == JsonToken.Boolean) { + + Type json_type = reader.Value.GetType (); + + if (value_type.IsAssignableFrom (json_type)) + return reader.Value; + + // If there's a custom importer that fits, use it + if (custom_importers_table.ContainsKey (json_type) && + custom_importers_table[json_type].ContainsKey ( + value_type)) { + + ImporterFunc importer = + custom_importers_table[json_type][value_type]; + + return importer (reader.Value); + } + + // Maybe there's a base importer that works + if (base_importers_table.ContainsKey (json_type) && + base_importers_table[json_type].ContainsKey ( + value_type)) { + + ImporterFunc importer = + base_importers_table[json_type][value_type]; + + return importer (reader.Value); + } + + // Maybe it's an enum + #if NETSTANDARD1_5 + if (value_type.IsEnum()) + return Enum.ToObject (value_type, reader.Value); + #else + if (value_type.IsEnum) + return Enum.ToObject (value_type, reader.Value); + #endif + // Try using an implicit conversion operator + MethodInfo conv_op = GetConvOp (value_type, json_type); + + if (conv_op != null) + return conv_op.Invoke (null, + new object[] { reader.Value }); + + // No luck + throw new JsonException (String.Format ( + "Can't assign value '{0}' (type {1}) to type {2}", + reader.Value, json_type, inst_type)); + } + + object instance = null; + + if (reader.Token == JsonToken.ArrayStart) { + + AddArrayMetadata (inst_type); + ArrayMetadata t_data = array_metadata[inst_type]; + + if (! t_data.IsArray && ! t_data.IsList) + throw new JsonException (String.Format ( + "Type {0} can't act as an array", + inst_type)); + + IList list; + Type elem_type; + + if (! t_data.IsArray) { + list = (IList) Activator.CreateInstance (inst_type); + elem_type = t_data.ElementType; + } else { + list = new ArrayList (); + elem_type = inst_type.GetElementType (); + } + + list.Clear(); + + while (true) { + object item = ReadValue (elem_type, reader); + if (item == null && reader.Token == JsonToken.ArrayEnd) + break; + + list.Add (item); + } + + if (t_data.IsArray) { + int n = list.Count; + instance = Array.CreateInstance (elem_type, n); + + for (int i = 0; i < n; i++) + ((Array) instance).SetValue (list[i], i); + } else + instance = list; + + } else if (reader.Token == JsonToken.ObjectStart) { + AddObjectMetadata (value_type); + ObjectMetadata t_data = object_metadata[value_type]; + + instance = Activator.CreateInstance (value_type); + + while (true) { + reader.Read (); + + if (reader.Token == JsonToken.ObjectEnd) + break; + + string property = (string) reader.Value; + + if (t_data.Properties.ContainsKey (property)) { + PropertyMetadata prop_data = + t_data.Properties[property]; + + if (prop_data.IsField) { + ((FieldInfo) prop_data.Info).SetValue ( + instance, ReadValue (prop_data.Type, reader)); + } else { + PropertyInfo p_info = + (PropertyInfo) prop_data.Info; + + if (p_info.CanWrite) + p_info.SetValue ( + instance, + ReadValue (prop_data.Type, reader), + null); + else + ReadValue (prop_data.Type, reader); + } + + } else { + if (! t_data.IsDictionary) { + + if (! reader.SkipNonMembers) { + throw new JsonException (String.Format ( + "The type {0} doesn't have the " + + "property '{1}'", + inst_type, property)); + } else { + ReadSkip (reader); + continue; + } + } + + ((IDictionary) instance).Add ( + property, ReadValue ( + t_data.ElementType, reader)); + } + + } + + } + + return instance; + } + + private static IJsonWrapper ReadValue (WrapperFactory factory, + JsonReader reader) + { + reader.Read (); + + if (reader.Token == JsonToken.ArrayEnd || + reader.Token == JsonToken.Null) + return null; + + IJsonWrapper instance = factory (); + + if (reader.Token == JsonToken.String) { + instance.SetString ((string) reader.Value); + return instance; + } + + if (reader.Token == JsonToken.Double) { + instance.SetDouble ((double) reader.Value); + return instance; + } + + if (reader.Token == JsonToken.Int) { + instance.SetInt ((int) reader.Value); + return instance; + } + + if (reader.Token == JsonToken.Long) { + instance.SetLong ((long) reader.Value); + return instance; + } + + if (reader.Token == JsonToken.Boolean) { + instance.SetBoolean ((bool) reader.Value); + return instance; + } + + if (reader.Token == JsonToken.ArrayStart) { + instance.SetJsonType (JsonType.Array); + + while (true) { + IJsonWrapper item = ReadValue (factory, reader); + if (item == null && reader.Token == JsonToken.ArrayEnd) + break; + + ((IList) instance).Add (item); + } + } + else if (reader.Token == JsonToken.ObjectStart) { + instance.SetJsonType (JsonType.Object); + + while (true) { + reader.Read (); + + if (reader.Token == JsonToken.ObjectEnd) + break; + + string property = (string) reader.Value; + + ((IDictionary) instance)[property] = ReadValue ( + factory, reader); + } + + } + + return instance; + } + + private static void ReadSkip (JsonReader reader) + { + ToWrapper ( + delegate { return new JsonMockWrapper (); }, reader); + } + + private static void RegisterBaseExporters () + { + base_exporters_table[typeof (byte)] = + delegate (object obj, JsonWriter writer) { + writer.Write (Convert.ToInt32 ((byte) obj)); + }; + + base_exporters_table[typeof (char)] = + delegate (object obj, JsonWriter writer) { + writer.Write (Convert.ToString ((char) obj)); + }; + + base_exporters_table[typeof (DateTime)] = + delegate (object obj, JsonWriter writer) { + writer.Write (Convert.ToString ((DateTime) obj, + datetime_format)); + }; + + base_exporters_table[typeof (decimal)] = + delegate (object obj, JsonWriter writer) { + writer.Write ((decimal) obj); + }; + + base_exporters_table[typeof (sbyte)] = + delegate (object obj, JsonWriter writer) { + writer.Write (Convert.ToInt32 ((sbyte) obj)); + }; + + base_exporters_table[typeof (short)] = + delegate (object obj, JsonWriter writer) { + writer.Write (Convert.ToInt32 ((short) obj)); + }; + + base_exporters_table[typeof (ushort)] = + delegate (object obj, JsonWriter writer) { + writer.Write (Convert.ToInt32 ((ushort) obj)); + }; + + base_exporters_table[typeof (uint)] = + delegate (object obj, JsonWriter writer) { + writer.Write (Convert.ToUInt64 ((uint) obj)); + }; + + base_exporters_table[typeof (ulong)] = + delegate (object obj, JsonWriter writer) { + writer.Write ((ulong) obj); + }; + + base_exporters_table[typeof(DateTimeOffset)] = + delegate (object obj, JsonWriter writer) { + writer.Write(((DateTimeOffset)obj).ToString("yyyy-MM-ddTHH:mm:ss.fffffffzzz", datetime_format)); + }; + } + + private static void RegisterBaseImporters () + { + ImporterFunc importer; + + importer = delegate (object input) { + return Convert.ToByte ((int) input); + }; + RegisterImporter (base_importers_table, typeof (int), + typeof (byte), importer); + + importer = delegate (object input) { + return Convert.ToUInt64 ((int) input); + }; + RegisterImporter (base_importers_table, typeof (int), + typeof (ulong), importer); + + importer = delegate (object input) { + return Convert.ToInt64((int)input); + }; + RegisterImporter(base_importers_table, typeof(int), + typeof(long), importer); + + importer = delegate (object input) { + return Convert.ToSByte ((int) input); + }; + RegisterImporter (base_importers_table, typeof (int), + typeof (sbyte), importer); + + importer = delegate (object input) { + return Convert.ToInt16 ((int) input); + }; + RegisterImporter (base_importers_table, typeof (int), + typeof (short), importer); + + importer = delegate (object input) { + return Convert.ToUInt16 ((int) input); + }; + RegisterImporter (base_importers_table, typeof (int), + typeof (ushort), importer); + + importer = delegate (object input) { + return Convert.ToUInt32 ((int) input); + }; + RegisterImporter (base_importers_table, typeof (int), + typeof (uint), importer); + + importer = delegate (object input) { + return Convert.ToSingle ((int) input); + }; + RegisterImporter (base_importers_table, typeof (int), + typeof (float), importer); + + importer = delegate (object input) { + return Convert.ToDouble ((int) input); + }; + RegisterImporter (base_importers_table, typeof (int), + typeof (double), importer); + + importer = delegate (object input) { + return Convert.ToDecimal ((double) input); + }; + RegisterImporter (base_importers_table, typeof (double), + typeof (decimal), importer); + + importer = delegate (object input) { + return Convert.ToSingle((double)input); + }; + RegisterImporter(base_importers_table, typeof(double), + typeof(float), importer); + + importer = delegate (object input) { + return Convert.ToUInt32 ((long) input); + }; + RegisterImporter (base_importers_table, typeof (long), + typeof (uint), importer); + + importer = delegate (object input) { + return Convert.ToChar ((string) input); + }; + RegisterImporter (base_importers_table, typeof (string), + typeof (char), importer); + + importer = delegate (object input) { + return Convert.ToDateTime ((string) input, datetime_format); + }; + RegisterImporter (base_importers_table, typeof (string), + typeof (DateTime), importer); + + importer = delegate (object input) { + return DateTimeOffset.Parse((string)input, datetime_format); + }; + RegisterImporter(base_importers_table, typeof(string), + typeof(DateTimeOffset), importer); + } + + private static void RegisterImporter ( + IDictionary> table, + Type json_type, Type value_type, ImporterFunc importer) + { + if (! table.ContainsKey (json_type)) + table.Add (json_type, new Dictionary ()); + + table[json_type][value_type] = importer; + } + + private static void WriteValue (object obj, JsonWriter writer, + bool writer_is_private, + int depth) + { + if (depth > max_nesting_depth) + throw new JsonException ( + String.Format ("Max allowed object depth reached while " + + "trying to export from type {0}", + obj.GetType ())); + + if (obj == null) { + writer.WriteObjectStart(); + writer.WriteObjectEnd(); + return; + } + + if (obj is IJsonWrapper) { + if (writer_is_private) + writer.TextWriter.Write (((IJsonWrapper) obj).ToJson ()); + else + ((IJsonWrapper) obj).ToJson (writer); + + return; + } + + if (obj is String) { + writer.Write ((string) obj); + return; + } + + if (obj is Double) { + writer.Write ((double) obj); + return; + } + + if (obj is Single) + { + writer.Write((float)obj); + return; + } + + if (obj is Int32) { + writer.Write ((int) obj); + return; + } + + if (obj is Boolean) { + writer.Write ((bool) obj); + return; + } + + if (obj is Int64) { + writer.Write ((long) obj); + return; + } + + if (obj is Array) { + writer.WriteArrayStart (); + + foreach (object elem in (Array) obj) + WriteValue (elem, writer, writer_is_private, depth + 1); + + writer.WriteArrayEnd (); + + return; + } + + if (obj is IList) { + writer.WriteArrayStart (); + foreach (object elem in (IList) obj) + WriteValue (elem, writer, writer_is_private, depth + 1); + writer.WriteArrayEnd (); + + return; + } + + if (obj is IDictionary dictionary) { + writer.WriteObjectStart (); + foreach (DictionaryEntry entry in dictionary) { + var propertyName = entry.Key is string key ? + key + : Convert.ToString(entry.Key, CultureInfo.InvariantCulture); + writer.WritePropertyName (propertyName); + WriteValue (entry.Value, writer, writer_is_private, + depth + 1); + } + writer.WriteObjectEnd (); + + return; + } + + Type obj_type = obj.GetType (); + + // See if there's a custom exporter for the object + if (custom_exporters_table.ContainsKey (obj_type)) { + ExporterFunc exporter = custom_exporters_table[obj_type]; + exporter (obj, writer); + + return; + } + + // If not, maybe there's a base exporter + if (base_exporters_table.ContainsKey (obj_type)) { + ExporterFunc exporter = base_exporters_table[obj_type]; + exporter (obj, writer); + + return; + } + + // Last option, let's see if it's an enum + if (obj is Enum) { + Type e_type = Enum.GetUnderlyingType (obj_type); + + if (e_type == typeof (long)) + writer.Write ((long) obj); + else if (e_type == typeof (uint)) + writer.Write ((uint) obj); + else if (e_type == typeof (ulong)) + writer.Write ((ulong) obj); + else if (e_type == typeof(ushort)) + writer.Write ((ushort)obj); + else if (e_type == typeof(short)) + writer.Write ((short)obj); + else if (e_type == typeof(byte)) + writer.Write ((byte)obj); + else if (e_type == typeof(sbyte)) + writer.Write ((sbyte)obj); + else + writer.Write ((int) obj); + + return; + } + + // Okay, so it looks like the input should be exported as an + // object + AddTypeProperties (obj_type); + IList props = type_properties[obj_type]; + + writer.WriteObjectStart (); + foreach (PropertyMetadata p_data in props) { + if (p_data.IsField) { + writer.WritePropertyName (p_data.Info.Name); + WriteValue (((FieldInfo) p_data.Info).GetValue (obj), + writer, writer_is_private, depth + 1); + } + else { + PropertyInfo p_info = (PropertyInfo) p_data.Info; + + if (p_info.CanRead) { + writer.WritePropertyName (p_data.Info.Name); + WriteValue (p_info.GetValue (obj, null), + writer, writer_is_private, depth + 1); + } + } + } + writer.WriteObjectEnd (); + } + #endregion + + + public static string ToJson (object obj) + { + lock (static_writer_lock) { + static_writer.Reset (); + + WriteValue (obj, static_writer, true, 0); + + return static_writer.ToString (); + } + } + + public static void ToJson (object obj, JsonWriter writer) + { + WriteValue (obj, writer, false, 0); + } + + public static JsonData ToObject (JsonReader reader) + { + return (JsonData) ToWrapper ( + delegate { return new JsonData (); }, reader); + } + + public static JsonData ToObject (TextReader reader) + { + JsonReader json_reader = new JsonReader (reader); + + return (JsonData) ToWrapper ( + delegate { return new JsonData (); }, json_reader); + } + + public static JsonData ToObject (string json) + { + return (JsonData) ToWrapper ( + delegate { return new JsonData (); }, json); + } + + public static T ToObject (JsonReader reader) + { + return (T) ReadValue (typeof (T), reader); + } + + public static T ToObject (TextReader reader) + { + JsonReader json_reader = new JsonReader (reader); + + return (T) ReadValue (typeof (T), json_reader); + } + + public static T ToObject (string json) + { + JsonReader reader = new JsonReader (json); + + return (T) ReadValue (typeof (T), reader); + } + + public static object ToObject(string json, Type ConvertType ) + { + JsonReader reader = new JsonReader(json); + + return ReadValue(ConvertType, reader); + } + + public static IJsonWrapper ToWrapper (WrapperFactory factory, + JsonReader reader) + { + return ReadValue (factory, reader); + } + + public static IJsonWrapper ToWrapper (WrapperFactory factory, + string json) + { + JsonReader reader = new JsonReader (json); + + return ReadValue (factory, reader); + } + + public static void RegisterExporter (ExporterFunc exporter) + { + ExporterFunc exporter_wrapper = + delegate (object obj, JsonWriter writer) { + exporter ((T) obj, writer); + }; + + custom_exporters_table[typeof (T)] = exporter_wrapper; + } + + public static void RegisterImporter ( + ImporterFunc importer) + { + ImporterFunc importer_wrapper = + delegate (object input) { + return importer ((TJson) input); + }; + + RegisterImporter (custom_importers_table, typeof (TJson), + typeof (TValue), importer_wrapper); + } + + public static void UnregisterExporters () + { + custom_exporters_table.Clear (); + } + + public static void UnregisterImporters () + { + custom_importers_table.Clear (); + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonMapper.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonMapper.cs.meta new file mode 100644 index 0000000..e8f9274 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonMapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bf17ecb2746364960bb598cc139f474e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonMockWrapper.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonMockWrapper.cs new file mode 100644 index 0000000..40d1c46 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonMockWrapper.cs @@ -0,0 +1,105 @@ +#region Header +/** + * JsonMockWrapper.cs + * Mock object implementing IJsonWrapper, to facilitate actions like + * skipping data more efficiently. + * + * The authors disclaim copyright to this source code. For more details, see + * the COPYING file included with this distribution. + **/ +#endregion + + +using System; +using System.Collections; +using System.Collections.Specialized; + + +namespace AnyThinkAds.ThirdParty.LitJson +{ + public class JsonMockWrapper : IJsonWrapper + { + public bool IsArray { get { return false; } } + public bool IsBoolean { get { return false; } } + public bool IsDouble { get { return false; } } + public bool IsInt { get { return false; } } + public bool IsLong { get { return false; } } + public bool IsObject { get { return false; } } + public bool IsString { get { return false; } } + + public bool GetBoolean () { return false; } + public double GetDouble () { return 0.0; } + public int GetInt () { return 0; } + public JsonType GetJsonType () { return JsonType.None; } + public long GetLong () { return 0L; } + public string GetString () { return ""; } + + public void SetBoolean (bool val) {} + public void SetDouble (double val) {} + public void SetInt (int val) {} + public void SetJsonType (JsonType type) {} + public void SetLong (long val) {} + public void SetString (string val) {} + + public string ToJson () { return ""; } + public void ToJson (JsonWriter writer) {} + + + bool IList.IsFixedSize { get { return true; } } + bool IList.IsReadOnly { get { return true; } } + + object IList.this[int index] { + get { return null; } + set {} + } + + int IList.Add (object value) { return 0; } + void IList.Clear () {} + bool IList.Contains (object value) { return false; } + int IList.IndexOf (object value) { return -1; } + void IList.Insert (int i, object v) {} + void IList.Remove (object value) {} + void IList.RemoveAt (int index) {} + + + int ICollection.Count { get { return 0; } } + bool ICollection.IsSynchronized { get { return false; } } + object ICollection.SyncRoot { get { return null; } } + + void ICollection.CopyTo (Array array, int index) {} + + + IEnumerator IEnumerable.GetEnumerator () { return null; } + + + bool IDictionary.IsFixedSize { get { return true; } } + bool IDictionary.IsReadOnly { get { return true; } } + + ICollection IDictionary.Keys { get { return null; } } + ICollection IDictionary.Values { get { return null; } } + + object IDictionary.this[object key] { + get { return null; } + set {} + } + + void IDictionary.Add (object k, object v) {} + void IDictionary.Clear () {} + bool IDictionary.Contains (object key) { return false; } + void IDictionary.Remove (object key) {} + + IDictionaryEnumerator IDictionary.GetEnumerator () { return null; } + + + object IOrderedDictionary.this[int idx] { + get { return null; } + set {} + } + + IDictionaryEnumerator IOrderedDictionary.GetEnumerator () { + return null; + } + void IOrderedDictionary.Insert (int i, object k, object v) {} + void IOrderedDictionary.RemoveAt (int i) {} + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonMockWrapper.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonMockWrapper.cs.meta new file mode 100644 index 0000000..984ad0f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonMockWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c636f684deb3f454399929073c7ef4d9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonReader.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonReader.cs new file mode 100644 index 0000000..543f066 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonReader.cs @@ -0,0 +1,478 @@ +#region Header +/** + * JsonReader.cs + * Stream-like access to JSON text. + * + * The authors disclaim copyright to this source code. For more details, see + * the COPYING file included with this distribution. + **/ +#endregion + + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Text; + + +namespace AnyThinkAds.ThirdParty.LitJson +{ + public enum JsonToken + { + None, + + ObjectStart, + PropertyName, + ObjectEnd, + + ArrayStart, + ArrayEnd, + + Int, + Long, + Double, + + String, + + Boolean, + Null + } + + + public class JsonReader + { + #region Fields + private static readonly IDictionary> parse_table; + + private Stack automaton_stack; + private int current_input; + private int current_symbol; + private bool end_of_json; + private bool end_of_input; + private Lexer lexer; + private bool parser_in_string; + private bool parser_return; + private bool read_started; + private TextReader reader; + private bool reader_is_owned; + private bool skip_non_members; + private object token_value; + private JsonToken token; + #endregion + + + #region Public Properties + public bool AllowComments { + get { return lexer.AllowComments; } + set { lexer.AllowComments = value; } + } + + public bool AllowSingleQuotedStrings { + get { return lexer.AllowSingleQuotedStrings; } + set { lexer.AllowSingleQuotedStrings = value; } + } + + public bool SkipNonMembers { + get { return skip_non_members; } + set { skip_non_members = value; } + } + + public bool EndOfInput { + get { return end_of_input; } + } + + public bool EndOfJson { + get { return end_of_json; } + } + + public JsonToken Token { + get { return token; } + } + + public object Value { + get { return token_value; } + } + #endregion + + + #region Constructors + static JsonReader () + { + parse_table = PopulateParseTable (); + } + + public JsonReader (string json_text) : + this (new StringReader (json_text), true) + { + } + + public JsonReader (TextReader reader) : + this (reader, false) + { + } + + private JsonReader (TextReader reader, bool owned) + { + if (reader == null) + throw new ArgumentNullException ("reader"); + + parser_in_string = false; + parser_return = false; + + read_started = false; + automaton_stack = new Stack (); + automaton_stack.Push ((int) ParserToken.End); + automaton_stack.Push ((int) ParserToken.Text); + + lexer = new Lexer (reader); + + end_of_input = false; + end_of_json = false; + + skip_non_members = true; + + this.reader = reader; + reader_is_owned = owned; + } + #endregion + + + #region Static Methods + private static IDictionary> PopulateParseTable () + { + // See section A.2. of the manual for details + IDictionary> parse_table = new Dictionary> (); + + TableAddRow (parse_table, ParserToken.Array); + TableAddCol (parse_table, ParserToken.Array, '[', + '[', + (int) ParserToken.ArrayPrime); + + TableAddRow (parse_table, ParserToken.ArrayPrime); + TableAddCol (parse_table, ParserToken.ArrayPrime, '"', + (int) ParserToken.Value, + + (int) ParserToken.ValueRest, + ']'); + TableAddCol (parse_table, ParserToken.ArrayPrime, '[', + (int) ParserToken.Value, + (int) ParserToken.ValueRest, + ']'); + TableAddCol (parse_table, ParserToken.ArrayPrime, ']', + ']'); + TableAddCol (parse_table, ParserToken.ArrayPrime, '{', + (int) ParserToken.Value, + (int) ParserToken.ValueRest, + ']'); + TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.Number, + (int) ParserToken.Value, + (int) ParserToken.ValueRest, + ']'); + TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.True, + (int) ParserToken.Value, + (int) ParserToken.ValueRest, + ']'); + TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.False, + (int) ParserToken.Value, + (int) ParserToken.ValueRest, + ']'); + TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.Null, + (int) ParserToken.Value, + (int) ParserToken.ValueRest, + ']'); + + TableAddRow (parse_table, ParserToken.Object); + TableAddCol (parse_table, ParserToken.Object, '{', + '{', + (int) ParserToken.ObjectPrime); + + TableAddRow (parse_table, ParserToken.ObjectPrime); + TableAddCol (parse_table, ParserToken.ObjectPrime, '"', + (int) ParserToken.Pair, + (int) ParserToken.PairRest, + '}'); + TableAddCol (parse_table, ParserToken.ObjectPrime, '}', + '}'); + + TableAddRow (parse_table, ParserToken.Pair); + TableAddCol (parse_table, ParserToken.Pair, '"', + (int) ParserToken.String, + ':', + (int) ParserToken.Value); + + TableAddRow (parse_table, ParserToken.PairRest); + TableAddCol (parse_table, ParserToken.PairRest, ',', + ',', + (int) ParserToken.Pair, + (int) ParserToken.PairRest); + TableAddCol (parse_table, ParserToken.PairRest, '}', + (int) ParserToken.Epsilon); + + TableAddRow (parse_table, ParserToken.String); + TableAddCol (parse_table, ParserToken.String, '"', + '"', + (int) ParserToken.CharSeq, + '"'); + + TableAddRow (parse_table, ParserToken.Text); + TableAddCol (parse_table, ParserToken.Text, '[', + (int) ParserToken.Array); + TableAddCol (parse_table, ParserToken.Text, '{', + (int) ParserToken.Object); + + TableAddRow (parse_table, ParserToken.Value); + TableAddCol (parse_table, ParserToken.Value, '"', + (int) ParserToken.String); + TableAddCol (parse_table, ParserToken.Value, '[', + (int) ParserToken.Array); + TableAddCol (parse_table, ParserToken.Value, '{', + (int) ParserToken.Object); + TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.Number, + (int) ParserToken.Number); + TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.True, + (int) ParserToken.True); + TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.False, + (int) ParserToken.False); + TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.Null, + (int) ParserToken.Null); + + TableAddRow (parse_table, ParserToken.ValueRest); + TableAddCol (parse_table, ParserToken.ValueRest, ',', + ',', + (int) ParserToken.Value, + (int) ParserToken.ValueRest); + TableAddCol (parse_table, ParserToken.ValueRest, ']', + (int) ParserToken.Epsilon); + + return parse_table; + } + + private static void TableAddCol (IDictionary> parse_table, ParserToken row, int col, + params int[] symbols) + { + parse_table[(int) row].Add (col, symbols); + } + + private static void TableAddRow (IDictionary> parse_table, ParserToken rule) + { + parse_table.Add ((int) rule, new Dictionary ()); + } + #endregion + + + #region Private Methods + private void ProcessNumber (string number) + { + if (number.IndexOf ('.') != -1 || + number.IndexOf ('e') != -1 || + number.IndexOf ('E') != -1) { + + double n_double; + if (double.TryParse (number, NumberStyles.Any, CultureInfo.InvariantCulture, out n_double)) { + token = JsonToken.Double; + token_value = n_double; + + return; + } + } + + int n_int32; + if (int.TryParse (number, NumberStyles.Integer, CultureInfo.InvariantCulture, out n_int32)) { + token = JsonToken.Int; + token_value = n_int32; + + return; + } + + long n_int64; + if (long.TryParse (number, NumberStyles.Integer, CultureInfo.InvariantCulture, out n_int64)) { + token = JsonToken.Long; + token_value = n_int64; + + return; + } + + ulong n_uint64; + if (ulong.TryParse(number, NumberStyles.Integer, CultureInfo.InvariantCulture, out n_uint64)) + { + token = JsonToken.Long; + token_value = n_uint64; + + return; + } + + // Shouldn't happen, but just in case, return something + token = JsonToken.Int; + token_value = 0; + } + + private void ProcessSymbol () + { + if (current_symbol == '[') { + token = JsonToken.ArrayStart; + parser_return = true; + + } else if (current_symbol == ']') { + token = JsonToken.ArrayEnd; + parser_return = true; + + } else if (current_symbol == '{') { + token = JsonToken.ObjectStart; + parser_return = true; + + } else if (current_symbol == '}') { + token = JsonToken.ObjectEnd; + parser_return = true; + + } else if (current_symbol == '"') { + if (parser_in_string) { + parser_in_string = false; + + parser_return = true; + + } else { + if (token == JsonToken.None) + token = JsonToken.String; + + parser_in_string = true; + } + + } else if (current_symbol == (int) ParserToken.CharSeq) { + token_value = lexer.StringValue; + + } else if (current_symbol == (int) ParserToken.False) { + token = JsonToken.Boolean; + token_value = false; + parser_return = true; + + } else if (current_symbol == (int) ParserToken.Null) { + token = JsonToken.Null; + parser_return = true; + + } else if (current_symbol == (int) ParserToken.Number) { + ProcessNumber (lexer.StringValue); + + parser_return = true; + + } else if (current_symbol == (int) ParserToken.Pair) { + token = JsonToken.PropertyName; + + } else if (current_symbol == (int) ParserToken.True) { + token = JsonToken.Boolean; + token_value = true; + parser_return = true; + + } + } + + private bool ReadToken () + { + if (end_of_input) + return false; + + lexer.NextToken (); + + if (lexer.EndOfInput) { + Close (); + + return false; + } + + current_input = lexer.Token; + + return true; + } + #endregion + + + public void Close () + { + if (end_of_input) + return; + + end_of_input = true; + end_of_json = true; + + if (reader_is_owned) + { + using(reader){} + } + + reader = null; + } + + public bool Read () + { + if (end_of_input) + return false; + + if (end_of_json) { + end_of_json = false; + automaton_stack.Clear (); + automaton_stack.Push ((int) ParserToken.End); + automaton_stack.Push ((int) ParserToken.Text); + } + + parser_in_string = false; + parser_return = false; + + token = JsonToken.None; + token_value = null; + + if (! read_started) { + read_started = true; + + if (! ReadToken ()) + return false; + } + + + int[] entry_symbols; + + while (true) { + if (parser_return) { + if (automaton_stack.Peek () == (int) ParserToken.End) + end_of_json = true; + + return true; + } + + current_symbol = automaton_stack.Pop (); + + ProcessSymbol (); + + if (current_symbol == current_input) { + if (! ReadToken ()) { + if (automaton_stack.Peek () != (int) ParserToken.End) + throw new JsonException ( + "Input doesn't evaluate to proper JSON text"); + + if (parser_return) + return true; + + return false; + } + + continue; + } + + try { + + entry_symbols = + parse_table[current_symbol][current_input]; + + } catch (KeyNotFoundException e) { + throw new JsonException ((ParserToken) current_input, e); + } + + if (entry_symbols[0] == (int) ParserToken.Epsilon) + continue; + + for (int i = entry_symbols.Length - 1; i >= 0; i--) + automaton_stack.Push (entry_symbols[i]); + } + } + + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonReader.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonReader.cs.meta new file mode 100644 index 0000000..b4ee6e1 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonReader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 10f4feced6ef548d8a0388f55ec380ea +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonWriter.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonWriter.cs new file mode 100644 index 0000000..962a9ea --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonWriter.cs @@ -0,0 +1,484 @@ +#region Header +/** + * JsonWriter.cs + * Stream-like facility to output JSON text. + * + * The authors disclaim copyright to this source code. For more details, see + * the COPYING file included with this distribution. + **/ +#endregion + + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Text; + + +namespace AnyThinkAds.ThirdParty.LitJson +{ + internal enum Condition + { + InArray, + InObject, + NotAProperty, + Property, + Value + } + + internal class WriterContext + { + public int Count; + public bool InArray; + public bool InObject; + public bool ExpectingValue; + public int Padding; + } + + public class JsonWriter + { + #region Fields + private static readonly NumberFormatInfo number_format; + + private WriterContext context; + private Stack ctx_stack; + private bool has_reached_end; + private char[] hex_seq; + private int indentation; + private int indent_value; + private StringBuilder inst_string_builder; + private bool pretty_print; + private bool validate; + private bool lower_case_properties; + private TextWriter writer; + #endregion + + + #region Properties + public int IndentValue { + get { return indent_value; } + set { + indentation = (indentation / indent_value) * value; + indent_value = value; + } + } + + public bool PrettyPrint { + get { return pretty_print; } + set { pretty_print = value; } + } + + public TextWriter TextWriter { + get { return writer; } + } + + public bool Validate { + get { return validate; } + set { validate = value; } + } + + public bool LowerCaseProperties { + get { return lower_case_properties; } + set { lower_case_properties = value; } + } + #endregion + + + #region Constructors + static JsonWriter () + { + number_format = NumberFormatInfo.InvariantInfo; + } + + public JsonWriter () + { + inst_string_builder = new StringBuilder (); + writer = new StringWriter (inst_string_builder); + + Init (); + } + + public JsonWriter (StringBuilder sb) : + this (new StringWriter (sb)) + { + } + + public JsonWriter (TextWriter writer) + { + if (writer == null) + throw new ArgumentNullException ("writer"); + + this.writer = writer; + + Init (); + } + #endregion + + + #region Private Methods + private void DoValidation (Condition cond) + { + if (! context.ExpectingValue) + context.Count++; + + if (! validate) + return; + + if (has_reached_end) + throw new JsonException ( + "A complete JSON symbol has already been written"); + + switch (cond) { + case Condition.InArray: + if (! context.InArray) + throw new JsonException ( + "Can't close an array here"); + break; + + case Condition.InObject: + if (! context.InObject || context.ExpectingValue) + throw new JsonException ( + "Can't close an object here"); + break; + + case Condition.NotAProperty: + if (context.InObject && ! context.ExpectingValue) + throw new JsonException ( + "Expected a property"); + break; + + case Condition.Property: + if (! context.InObject || context.ExpectingValue) + throw new JsonException ( + "Can't add a property here"); + break; + + case Condition.Value: + if (! context.InArray && + (! context.InObject || ! context.ExpectingValue)) + throw new JsonException ( + "Can't add a value here"); + + break; + } + } + + private void Init () + { + has_reached_end = false; + hex_seq = new char[4]; + indentation = 0; + indent_value = 4; + pretty_print = false; + validate = true; + lower_case_properties = false; + + ctx_stack = new Stack (); + context = new WriterContext (); + ctx_stack.Push (context); + } + + private static void IntToHex (int n, char[] hex) + { + int num; + + for (int i = 0; i < 4; i++) { + num = n % 16; + + if (num < 10) + hex[3 - i] = (char) ('0' + num); + else + hex[3 - i] = (char) ('A' + (num - 10)); + + n >>= 4; + } + } + + private void Indent () + { + if (pretty_print) + indentation += indent_value; + } + + + private void Put (string str) + { + if (pretty_print && ! context.ExpectingValue) + for (int i = 0; i < indentation; i++) + writer.Write (' '); + + writer.Write (str); + } + + private void PutNewline () + { + PutNewline (true); + } + + private void PutNewline (bool add_comma) + { + if (add_comma && ! context.ExpectingValue && + context.Count > 1) + writer.Write (','); + + if (pretty_print && ! context.ExpectingValue) + writer.Write (Environment.NewLine); + } + + private void PutString (string str) + { + Put (String.Empty); + + writer.Write ('"'); + + int n = str.Length; + for (int i = 0; i < n; i++) { + switch (str[i]) { + case '\n': + writer.Write ("\\n"); + continue; + + case '\r': + writer.Write ("\\r"); + continue; + + case '\t': + writer.Write ("\\t"); + continue; + + case '"': + case '\\': + writer.Write ('\\'); + writer.Write (str[i]); + continue; + + case '\f': + writer.Write ("\\f"); + continue; + + case '\b': + writer.Write ("\\b"); + continue; + } + + if ((int) str[i] >= 32 && (int) str[i] <= 126) { + writer.Write (str[i]); + continue; + } + + // Default, turn into a \uXXXX sequence + IntToHex ((int) str[i], hex_seq); + writer.Write ("\\u"); + writer.Write (hex_seq); + } + + writer.Write ('"'); + } + + private void Unindent () + { + if (pretty_print) + indentation -= indent_value; + } + #endregion + + + public override string ToString () + { + if (inst_string_builder == null) + return String.Empty; + + return inst_string_builder.ToString (); + } + + public void Reset () + { + has_reached_end = false; + + ctx_stack.Clear (); + context = new WriterContext (); + ctx_stack.Push (context); + + if (inst_string_builder != null) + inst_string_builder.Remove (0, inst_string_builder.Length); + } + + public void Write (bool boolean) + { + DoValidation (Condition.Value); + PutNewline (); + + Put (boolean ? "true" : "false"); + + context.ExpectingValue = false; + } + + public void Write (decimal number) + { + DoValidation (Condition.Value); + PutNewline (); + + Put (Convert.ToString (number, number_format)); + + context.ExpectingValue = false; + } + + public void Write (double number) + { + DoValidation (Condition.Value); + PutNewline (); + + string str = Convert.ToString (number, number_format); + Put (str); + + if (str.IndexOf ('.') == -1 && + str.IndexOf ('E') == -1) + writer.Write (".0"); + + context.ExpectingValue = false; + } + + public void Write(float number) + { + DoValidation(Condition.Value); + PutNewline(); + + string str = Convert.ToString(number, number_format); + Put(str); + + context.ExpectingValue = false; + } + + public void Write (int number) + { + DoValidation (Condition.Value); + PutNewline (); + + Put (Convert.ToString (number, number_format)); + + context.ExpectingValue = false; + } + + public void Write (long number) + { + DoValidation (Condition.Value); + PutNewline (); + + Put (Convert.ToString (number, number_format)); + + context.ExpectingValue = false; + } + + public void Write (string str) + { + DoValidation (Condition.Value); + PutNewline (); + + if (str == null) + Put ("null"); + else + PutString (str); + + context.ExpectingValue = false; + } + + [CLSCompliant(false)] + public void Write (ulong number) + { + DoValidation (Condition.Value); + PutNewline (); + + Put (Convert.ToString (number, number_format)); + + context.ExpectingValue = false; + } + + public void WriteArrayEnd () + { + DoValidation (Condition.InArray); + PutNewline (false); + + ctx_stack.Pop (); + if (ctx_stack.Count == 1) + has_reached_end = true; + else { + context = ctx_stack.Peek (); + context.ExpectingValue = false; + } + + Unindent (); + Put ("]"); + } + + public void WriteArrayStart () + { + DoValidation (Condition.NotAProperty); + PutNewline (); + + Put ("["); + + context = new WriterContext (); + context.InArray = true; + ctx_stack.Push (context); + + Indent (); + } + + public void WriteObjectEnd () + { + DoValidation (Condition.InObject); + PutNewline (false); + + ctx_stack.Pop (); + if (ctx_stack.Count == 1) + has_reached_end = true; + else { + context = ctx_stack.Peek (); + context.ExpectingValue = false; + } + + Unindent (); + Put ("}"); + } + + public void WriteObjectStart () + { + DoValidation (Condition.NotAProperty); + PutNewline (); + + Put ("{"); + + context = new WriterContext (); + context.InObject = true; + ctx_stack.Push (context); + + Indent (); + } + + public void WritePropertyName (string property_name) + { + DoValidation (Condition.Property); + PutNewline (); + string propertyName = (property_name == null || !lower_case_properties) + ? property_name + : property_name.ToLowerInvariant(); + + PutString (propertyName); + + if (pretty_print) { + if (propertyName.Length > context.Padding) + context.Padding = propertyName.Length; + + for (int i = context.Padding - propertyName.Length; + i >= 0; i--) + writer.Write (' '); + + writer.Write (": "); + } else + writer.Write (':'); + + context.ExpectingValue = true; + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonWriter.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonWriter.cs.meta new file mode 100644 index 0000000..fd1d3d7 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/JsonWriter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eeeb961f4a5974c23905186270c49cca +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/Lexer.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/Lexer.cs new file mode 100644 index 0000000..82706af --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/Lexer.cs @@ -0,0 +1,912 @@ +#region Header +/** + * Lexer.cs + * JSON lexer implementation based on a finite state machine. + * + * The authors disclaim copyright to this source code. For more details, see + * the COPYING file included with this distribution. + **/ +#endregion + + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + + +namespace AnyThinkAds.ThirdParty.LitJson +{ + internal class FsmContext + { + public bool Return; + public int NextState; + public Lexer L; + public int StateStack; + } + + + internal class Lexer + { + #region Fields + private delegate bool StateHandler (FsmContext ctx); + + private static readonly int[] fsm_return_table; + private static readonly StateHandler[] fsm_handler_table; + + private bool allow_comments; + private bool allow_single_quoted_strings; + private bool end_of_input; + private FsmContext fsm_context; + private int input_buffer; + private int input_char; + private TextReader reader; + private int state; + private StringBuilder string_buffer; + private string string_value; + private int token; + private int unichar; + #endregion + + + #region Properties + public bool AllowComments { + get { return allow_comments; } + set { allow_comments = value; } + } + + public bool AllowSingleQuotedStrings { + get { return allow_single_quoted_strings; } + set { allow_single_quoted_strings = value; } + } + + public bool EndOfInput { + get { return end_of_input; } + } + + public int Token { + get { return token; } + } + + public string StringValue { + get { return string_value; } + } + #endregion + + + #region Constructors + static Lexer () + { + PopulateFsmTables (out fsm_handler_table, out fsm_return_table); + } + + public Lexer (TextReader reader) + { + allow_comments = true; + allow_single_quoted_strings = true; + + input_buffer = 0; + string_buffer = new StringBuilder (128); + state = 1; + end_of_input = false; + this.reader = reader; + + fsm_context = new FsmContext (); + fsm_context.L = this; + } + #endregion + + + #region Static Methods + private static int HexValue (int digit) + { + switch (digit) { + case 'a': + case 'A': + return 10; + + case 'b': + case 'B': + return 11; + + case 'c': + case 'C': + return 12; + + case 'd': + case 'D': + return 13; + + case 'e': + case 'E': + return 14; + + case 'f': + case 'F': + return 15; + + default: + return digit - '0'; + } + } + + private static void PopulateFsmTables (out StateHandler[] fsm_handler_table, out int[] fsm_return_table) + { + // See section A.1. of the manual for details of the finite + // state machine. + fsm_handler_table = new StateHandler[28] { + State1, + State2, + State3, + State4, + State5, + State6, + State7, + State8, + State9, + State10, + State11, + State12, + State13, + State14, + State15, + State16, + State17, + State18, + State19, + State20, + State21, + State22, + State23, + State24, + State25, + State26, + State27, + State28 + }; + + fsm_return_table = new int[28] { + (int) ParserToken.Char, + 0, + (int) ParserToken.Number, + (int) ParserToken.Number, + 0, + (int) ParserToken.Number, + 0, + (int) ParserToken.Number, + 0, + 0, + (int) ParserToken.True, + 0, + 0, + 0, + (int) ParserToken.False, + 0, + 0, + (int) ParserToken.Null, + (int) ParserToken.CharSeq, + (int) ParserToken.Char, + 0, + 0, + (int) ParserToken.CharSeq, + (int) ParserToken.Char, + 0, + 0, + 0, + 0 + }; + } + + private static char ProcessEscChar (int esc_char) + { + switch (esc_char) { + case '"': + case '\'': + case '\\': + case '/': + return Convert.ToChar (esc_char); + + case 'n': + return '\n'; + + case 't': + return '\t'; + + case 'r': + return '\r'; + + case 'b': + return '\b'; + + case 'f': + return '\f'; + + default: + // Unreachable + return '?'; + } + } + + private static bool State1 (FsmContext ctx) + { + while (ctx.L.GetChar ()) { + if (ctx.L.input_char == ' ' || + ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') + continue; + + if (ctx.L.input_char >= '1' && ctx.L.input_char <= '9') { + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + ctx.NextState = 3; + return true; + } + + switch (ctx.L.input_char) { + case '"': + ctx.NextState = 19; + ctx.Return = true; + return true; + + case ',': + case ':': + case '[': + case ']': + case '{': + case '}': + ctx.NextState = 1; + ctx.Return = true; + return true; + + case '-': + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + ctx.NextState = 2; + return true; + + case '0': + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + ctx.NextState = 4; + return true; + + case 'f': + ctx.NextState = 12; + return true; + + case 'n': + ctx.NextState = 16; + return true; + + case 't': + ctx.NextState = 9; + return true; + + case '\'': + if (! ctx.L.allow_single_quoted_strings) + return false; + + ctx.L.input_char = '"'; + ctx.NextState = 23; + ctx.Return = true; + return true; + + case '/': + if (! ctx.L.allow_comments) + return false; + + ctx.NextState = 25; + return true; + + default: + return false; + } + } + + return true; + } + + private static bool State2 (FsmContext ctx) + { + ctx.L.GetChar (); + + if (ctx.L.input_char >= '1' && ctx.L.input_char<= '9') { + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + ctx.NextState = 3; + return true; + } + + switch (ctx.L.input_char) { + case '0': + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + ctx.NextState = 4; + return true; + + default: + return false; + } + } + + private static bool State3 (FsmContext ctx) + { + while (ctx.L.GetChar ()) { + if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') { + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + continue; + } + + if (ctx.L.input_char == ' ' || + ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') { + ctx.Return = true; + ctx.NextState = 1; + return true; + } + + switch (ctx.L.input_char) { + case ',': + case ']': + case '}': + ctx.L.UngetChar (); + ctx.Return = true; + ctx.NextState = 1; + return true; + + case '.': + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + ctx.NextState = 5; + return true; + + case 'e': + case 'E': + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + ctx.NextState = 7; + return true; + + default: + return false; + } + } + return true; + } + + private static bool State4 (FsmContext ctx) + { + ctx.L.GetChar (); + + if (ctx.L.input_char == ' ' || + ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') { + ctx.Return = true; + ctx.NextState = 1; + return true; + } + + switch (ctx.L.input_char) { + case ',': + case ']': + case '}': + ctx.L.UngetChar (); + ctx.Return = true; + ctx.NextState = 1; + return true; + + case '.': + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + ctx.NextState = 5; + return true; + + case 'e': + case 'E': + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + ctx.NextState = 7; + return true; + + default: + return false; + } + } + + private static bool State5 (FsmContext ctx) + { + ctx.L.GetChar (); + + if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') { + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + ctx.NextState = 6; + return true; + } + + return false; + } + + private static bool State6 (FsmContext ctx) + { + while (ctx.L.GetChar ()) { + if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') { + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + continue; + } + + if (ctx.L.input_char == ' ' || + ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') { + ctx.Return = true; + ctx.NextState = 1; + return true; + } + + switch (ctx.L.input_char) { + case ',': + case ']': + case '}': + ctx.L.UngetChar (); + ctx.Return = true; + ctx.NextState = 1; + return true; + + case 'e': + case 'E': + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + ctx.NextState = 7; + return true; + + default: + return false; + } + } + + return true; + } + + private static bool State7 (FsmContext ctx) + { + ctx.L.GetChar (); + + if (ctx.L.input_char >= '0' && ctx.L.input_char<= '9') { + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + ctx.NextState = 8; + return true; + } + + switch (ctx.L.input_char) { + case '+': + case '-': + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + ctx.NextState = 8; + return true; + + default: + return false; + } + } + + private static bool State8 (FsmContext ctx) + { + while (ctx.L.GetChar ()) { + if (ctx.L.input_char >= '0' && ctx.L.input_char<= '9') { + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + continue; + } + + if (ctx.L.input_char == ' ' || + ctx.L.input_char >= '\t' && ctx.L.input_char<= '\r') { + ctx.Return = true; + ctx.NextState = 1; + return true; + } + + switch (ctx.L.input_char) { + case ',': + case ']': + case '}': + ctx.L.UngetChar (); + ctx.Return = true; + ctx.NextState = 1; + return true; + + default: + return false; + } + } + + return true; + } + + private static bool State9 (FsmContext ctx) + { + ctx.L.GetChar (); + + switch (ctx.L.input_char) { + case 'r': + ctx.NextState = 10; + return true; + + default: + return false; + } + } + + private static bool State10 (FsmContext ctx) + { + ctx.L.GetChar (); + + switch (ctx.L.input_char) { + case 'u': + ctx.NextState = 11; + return true; + + default: + return false; + } + } + + private static bool State11 (FsmContext ctx) + { + ctx.L.GetChar (); + + switch (ctx.L.input_char) { + case 'e': + ctx.Return = true; + ctx.NextState = 1; + return true; + + default: + return false; + } + } + + private static bool State12 (FsmContext ctx) + { + ctx.L.GetChar (); + + switch (ctx.L.input_char) { + case 'a': + ctx.NextState = 13; + return true; + + default: + return false; + } + } + + private static bool State13 (FsmContext ctx) + { + ctx.L.GetChar (); + + switch (ctx.L.input_char) { + case 'l': + ctx.NextState = 14; + return true; + + default: + return false; + } + } + + private static bool State14 (FsmContext ctx) + { + ctx.L.GetChar (); + + switch (ctx.L.input_char) { + case 's': + ctx.NextState = 15; + return true; + + default: + return false; + } + } + + private static bool State15 (FsmContext ctx) + { + ctx.L.GetChar (); + + switch (ctx.L.input_char) { + case 'e': + ctx.Return = true; + ctx.NextState = 1; + return true; + + default: + return false; + } + } + + private static bool State16 (FsmContext ctx) + { + ctx.L.GetChar (); + + switch (ctx.L.input_char) { + case 'u': + ctx.NextState = 17; + return true; + + default: + return false; + } + } + + private static bool State17 (FsmContext ctx) + { + ctx.L.GetChar (); + + switch (ctx.L.input_char) { + case 'l': + ctx.NextState = 18; + return true; + + default: + return false; + } + } + + private static bool State18 (FsmContext ctx) + { + ctx.L.GetChar (); + + switch (ctx.L.input_char) { + case 'l': + ctx.Return = true; + ctx.NextState = 1; + return true; + + default: + return false; + } + } + + private static bool State19 (FsmContext ctx) + { + while (ctx.L.GetChar ()) { + switch (ctx.L.input_char) { + case '"': + ctx.L.UngetChar (); + ctx.Return = true; + ctx.NextState = 20; + return true; + + case '\\': + ctx.StateStack = 19; + ctx.NextState = 21; + return true; + + default: + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + continue; + } + } + + return true; + } + + private static bool State20 (FsmContext ctx) + { + ctx.L.GetChar (); + + switch (ctx.L.input_char) { + case '"': + ctx.Return = true; + ctx.NextState = 1; + return true; + + default: + return false; + } + } + + private static bool State21 (FsmContext ctx) + { + ctx.L.GetChar (); + + switch (ctx.L.input_char) { + case 'u': + ctx.NextState = 22; + return true; + + case '"': + case '\'': + case '/': + case '\\': + case 'b': + case 'f': + case 'n': + case 'r': + case 't': + ctx.L.string_buffer.Append ( + ProcessEscChar (ctx.L.input_char)); + ctx.NextState = ctx.StateStack; + return true; + + default: + return false; + } + } + + private static bool State22 (FsmContext ctx) + { + int counter = 0; + int mult = 4096; + + ctx.L.unichar = 0; + + while (ctx.L.GetChar ()) { + + if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9' || + ctx.L.input_char >= 'A' && ctx.L.input_char <= 'F' || + ctx.L.input_char >= 'a' && ctx.L.input_char <= 'f') { + + ctx.L.unichar += HexValue (ctx.L.input_char) * mult; + + counter++; + mult /= 16; + + if (counter == 4) { + ctx.L.string_buffer.Append ( + Convert.ToChar (ctx.L.unichar)); + ctx.NextState = ctx.StateStack; + return true; + } + + continue; + } + + return false; + } + + return true; + } + + private static bool State23 (FsmContext ctx) + { + while (ctx.L.GetChar ()) { + switch (ctx.L.input_char) { + case '\'': + ctx.L.UngetChar (); + ctx.Return = true; + ctx.NextState = 24; + return true; + + case '\\': + ctx.StateStack = 23; + ctx.NextState = 21; + return true; + + default: + ctx.L.string_buffer.Append ((char) ctx.L.input_char); + continue; + } + } + + return true; + } + + private static bool State24 (FsmContext ctx) + { + ctx.L.GetChar (); + + switch (ctx.L.input_char) { + case '\'': + ctx.L.input_char = '"'; + ctx.Return = true; + ctx.NextState = 1; + return true; + + default: + return false; + } + } + + private static bool State25 (FsmContext ctx) + { + ctx.L.GetChar (); + + switch (ctx.L.input_char) { + case '*': + ctx.NextState = 27; + return true; + + case '/': + ctx.NextState = 26; + return true; + + default: + return false; + } + } + + private static bool State26 (FsmContext ctx) + { + while (ctx.L.GetChar ()) { + if (ctx.L.input_char == '\n') { + ctx.NextState = 1; + return true; + } + } + + return true; + } + + private static bool State27 (FsmContext ctx) + { + while (ctx.L.GetChar ()) { + if (ctx.L.input_char == '*') { + ctx.NextState = 28; + return true; + } + } + + return true; + } + + private static bool State28 (FsmContext ctx) + { + while (ctx.L.GetChar ()) { + if (ctx.L.input_char == '*') + continue; + + if (ctx.L.input_char == '/') { + ctx.NextState = 1; + return true; + } + + ctx.NextState = 27; + return true; + } + + return true; + } + #endregion + + + private bool GetChar () + { + if ((input_char = NextChar ()) != -1) + return true; + + end_of_input = true; + return false; + } + + private int NextChar () + { + if (input_buffer != 0) { + int tmp = input_buffer; + input_buffer = 0; + + return tmp; + } + + return reader.Read (); + } + + public bool NextToken () + { + StateHandler handler; + fsm_context.Return = false; + + while (true) { + handler = fsm_handler_table[state - 1]; + + if (! handler (fsm_context)) + throw new JsonException (input_char); + + if (end_of_input) + return false; + + if (fsm_context.Return) { + string_value = string_buffer.ToString (); + string_buffer.Remove (0, string_buffer.Length); + token = fsm_return_table[state - 1]; + + if (token == (int) ParserToken.Char) + token = input_char; + + state = fsm_context.NextState; + + return true; + } + + state = fsm_context.NextState; + } + } + + private void UngetChar () + { + input_buffer = input_char; + } + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/Lexer.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/Lexer.cs.meta new file mode 100644 index 0000000..f0e6838 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/Lexer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ca434eb8f9ae6455b926e74c8c5c4741 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/Netstandard15Polyfill.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/Netstandard15Polyfill.cs new file mode 100644 index 0000000..5766a3e --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/Netstandard15Polyfill.cs @@ -0,0 +1,24 @@ +#if NETSTANDARD1_5 +using System; +using System.Reflection; +namespace AnyThinkAds.ThirdParty.LitJson +{ + internal static class Netstandard15Polyfill + { + internal static Type GetInterface(this Type type, string name) + { + return type.GetTypeInfo().GetInterface(name); + } + + internal static bool IsClass(this Type type) + { + return type.GetTypeInfo().IsClass; + } + + internal static bool IsEnum(this Type type) + { + return type.GetTypeInfo().IsEnum; + } + } +} +#endif \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/Netstandard15Polyfill.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/Netstandard15Polyfill.cs.meta new file mode 100644 index 0000000..9d4e2d7 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/Netstandard15Polyfill.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f08583fc994b7468cb4d7993492d2d70 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/ParserToken.cs b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/ParserToken.cs new file mode 100644 index 0000000..2a55de5 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/ParserToken.cs @@ -0,0 +1,44 @@ +#region Header +/** + * ParserToken.cs + * Internal representation of the tokens used by the lexer and the parser. + * + * The authors disclaim copyright to this source code. For more details, see + * the COPYING file included with this distribution. + **/ +#endregion + + +namespace AnyThinkAds.ThirdParty.LitJson +{ + internal enum ParserToken + { + // Lexer tokens (see section A.1.1. of the manual) + None = System.Char.MaxValue + 1, + Number, + True, + False, + Null, + CharSeq, + // Single char + Char, + + // Parser Rules (see section A.2.1 of the manual) + Text, + Object, + ObjectPrime, + Pair, + PairRest, + Array, + ArrayPrime, + Value, + ValueRest, + String, + + // End of input + End, + + // The empty rule + Epsilon + } +} diff --git a/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/ParserToken.cs.meta b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/ParserToken.cs.meta new file mode 100644 index 0000000..7eef63b --- /dev/null +++ b/Assets/ThinkupTpnPlugin/AnyThinkAds/Thrid/ParserToken.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3408e5db5c99249dabb3786f5e73ef2d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Resources.meta b/Assets/ThinkupTpnPlugin/Resources.meta new file mode 100644 index 0000000..2ca67b9 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9d1727d001b46484392dd9ca27062c06 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Resources/Images.meta b/Assets/ThinkupTpnPlugin/Resources/Images.meta new file mode 100644 index 0000000..112847c --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Resources/Images.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 33edbaa5b5c9d441ab2ab82ea83fdfba +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Resources/Images/alert_icon.png b/Assets/ThinkupTpnPlugin/Resources/Images/alert_icon.png new file mode 100644 index 0000000..1651950 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/Resources/Images/alert_icon.png differ diff --git a/Assets/ThinkupTpnPlugin/Resources/Images/alert_icon.png.meta b/Assets/ThinkupTpnPlugin/Resources/Images/alert_icon.png.meta new file mode 100644 index 0000000..dffbecf --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Resources/Images/alert_icon.png.meta @@ -0,0 +1,127 @@ +fileFormatVersion: 2 +guid: 700aa46be6f714bfc93f4a9a0207802b +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Resources/Images/uninstall_icon.png b/Assets/ThinkupTpnPlugin/Resources/Images/uninstall_icon.png new file mode 100755 index 0000000..3b55354 Binary files /dev/null and b/Assets/ThinkupTpnPlugin/Resources/Images/uninstall_icon.png differ diff --git a/Assets/ThinkupTpnPlugin/Resources/Images/uninstall_icon.png.meta b/Assets/ThinkupTpnPlugin/Resources/Images/uninstall_icon.png.meta new file mode 100644 index 0000000..4c032dc --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Resources/Images/uninstall_icon.png.meta @@ -0,0 +1,127 @@ +fileFormatVersion: 2 +guid: 5721cdbb9b78a4ccf84ab4472aa09d06 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Resources/Images/warning_icon.png b/Assets/ThinkupTpnPlugin/Resources/Images/warning_icon.png new file mode 100644 index 0000000..cc9660e Binary files /dev/null and b/Assets/ThinkupTpnPlugin/Resources/Images/warning_icon.png differ diff --git a/Assets/ThinkupTpnPlugin/Resources/Images/warning_icon.png.meta b/Assets/ThinkupTpnPlugin/Resources/Images/warning_icon.png.meta new file mode 100644 index 0000000..7bafe4f --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Resources/Images/warning_icon.png.meta @@ -0,0 +1,127 @@ +fileFormatVersion: 2 +guid: 3647bc017a1bf4380bf1ec641c360db9 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Resources/json.meta b/Assets/ThinkupTpnPlugin/Resources/json.meta new file mode 100644 index 0000000..71847f3 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Resources/json.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6e4e1ddc215ab4315972edd685b59169 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Resources/json/2.1.5.meta b/Assets/ThinkupTpnPlugin/Resources/json/2.1.5.meta new file mode 100644 index 0000000..a5f5b78 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Resources/json/2.1.5.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7d4068a0877fa42afb00363127e03476 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Resources/json/2.1.5/plugin_hot_fix_data.json b/Assets/ThinkupTpnPlugin/Resources/json/2.1.5/plugin_hot_fix_data.json new file mode 100644 index 0000000..8c5c8d1 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Resources/json/2.1.5/plugin_hot_fix_data.json @@ -0,0 +1,7 @@ +{ + "status": 1, + "file_name": "AnyThinkHotFixPlugin_1.0.3.unitypackage", + "hot_fix_version": "1.0.3", + "download_url": "https://topon-sdk-release.oss-cn-hangzhou.aliyuncs.com/Unity_Release_Thinkup_TPN/plugin/2.1.5/hotfix/1.0.3/AnyThinkHotFixPlugin_1.0.3.unitypackage", + "plugin_version": "2.1.5" +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/Resources/json/2.1.5/plugin_hot_fix_data.json.meta b/Assets/ThinkupTpnPlugin/Resources/json/2.1.5/plugin_hot_fix_data.json.meta new file mode 100644 index 0000000..4ef7e88 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Resources/json/2.1.5/plugin_hot_fix_data.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5c7a00f4cc5414d578bff7565103fb64 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Resources/json/2.1.5/plugin_setting_data.json b/Assets/ThinkupTpnPlugin/Resources/json/2.1.5/plugin_setting_data.json new file mode 100644 index 0000000..baab087 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Resources/json/2.1.5/plugin_setting_data.json @@ -0,0 +1 @@ +{"curCountry":2,"china":{"android_version":"","ios_version":"","androidXSetting":0,"country":1,"android_admob_app_id":"","ios_admob_app_id":""},"nonchina":{"android_version":"6.4.88","ios_version":"","androidXSetting":0,"country":2,"android_admob_app_id":"","ios_admob_app_id":""}} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/Resources/json/2.1.5/plugin_setting_data.json.meta b/Assets/ThinkupTpnPlugin/Resources/json/2.1.5/plugin_setting_data.json.meta new file mode 100644 index 0000000..f6f6a1a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Resources/json/2.1.5/plugin_setting_data.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 616257b203b644734951ea1a935039f7 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script.meta b/Assets/ThinkupTpnPlugin/Script.meta new file mode 100644 index 0000000..e8f4e0e --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8fc552d17f4f7465c9e5179f32340de1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/Editor.meta b/Assets/ThinkupTpnPlugin/Script/Editor.meta new file mode 100644 index 0000000..cea835d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f159452a0569d41b1bf685a9ea78720f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/Editor/ATPostProcessBuildAndroid.cs b/Assets/ThinkupTpnPlugin/Script/Editor/ATPostProcessBuildAndroid.cs new file mode 100644 index 0000000..9533e59 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/Editor/ATPostProcessBuildAndroid.cs @@ -0,0 +1,330 @@ +#if UNITY_ANDROID && UNITY_2018_2_OR_NEWER +using AnyThink.Scripts.IntegrationManager.Editor; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Xml.Linq; +using UnityEditor; +using UnityEditor.Android; + +namespace AnyThink.Scripts.Editor +{ + public class ATPostProcessBuildAndroid: IPostGenerateGradleAndroidProject + { +#if UNITY_2019_3_OR_NEWER + private static string PropertyAndroidX = "android.useAndroidX"; + private static string PropertyJetifier = "android.enableJetifier"; + private static string EnableProperty = "=true"; +#endif + private static string PropertyDexingArtifactTransform = "android.enableDexingArtifactTransform"; + private static string DisableProperty = "=false"; + + private static string KeyMetaDataGoogleApplicationId = "com.google.android.gms.ads.APPLICATION_ID"; + private static string KeyMetaDataGoogleAdManagerApp = "com.google.android.gms.ads.AD_MANAGER_APP"; + + private static readonly XNamespace AndroidNamespace = "http://schemas.android.com/apk/res/android"; + private static readonly XNamespace ToolsNamespace = "http://schemas.android.com/tools"; + + public void OnPostGenerateGradleAndroidProject(string path) + { + ATLog.log("OnPostGenerateGradleAndroidProject() >>> path: " + path); + +#if UNITY_2019_3_OR_NEWER + var gradlePropertiesPath = Path.Combine(path, "../gradle.properties"); +#else + var gradlePropertiesPath = Path.Combine(path, "gradle.properties"); +#endif + if (!ATConfig.isDefaultAndroidX()) { + processGradleProperties(gradlePropertiesPath); + } + processAndroidManifest(path); + processNetworkConfigXml(path); + ATProcessBuildGradleAndroid.processBuildGradle(path); + } + + public int callbackOrder + { + get { return int.MaxValue; } + } + + private static void processGradleProperties(string gradlePropertiesPath) + { + ATLog.log("OnPostGenerateGradleAndroidProject() >>> gradlePropertiesPath: " + gradlePropertiesPath + " File.Exists(gradlePropertiesPath): " + File.Exists(gradlePropertiesPath)); + bool isChina = ATConfig.isSelectedChina(); + + var gradlePropertiesUpdated = new List(); + + // If the gradle properties file already exists, make sure to add any previous properties. + if (File.Exists(gradlePropertiesPath)) + { + var lines = File.ReadAllLines(gradlePropertiesPath); + +#if UNITY_2019_3_OR_NEWER + // Add all properties except AndroidX, Jetifier, and DexingArtifactTransform since they may already exist. We will re-add them below. + gradlePropertiesUpdated.AddRange(lines.Where(line => !line.Contains(PropertyAndroidX) && !line.Contains(PropertyJetifier) && !line.Contains(PropertyDexingArtifactTransform))); +#else + // Add all properties except DexingArtifactTransform since it may already exist. We will re-add it below. + gradlePropertiesUpdated.AddRange(lines.Where(line => !line.Contains(PropertyDexingArtifactTransform))); +#endif + } + +#if UNITY_2019_3_OR_NEWER + //如果是国内,则根据选择来决定是否用AndroidX + if (isChina) + { + if (!ATConfig.enableAndroidX()) { + EnableProperty = "=false"; + } else { + EnableProperty = "=true"; + } + } else { + EnableProperty = "=true"; + } + ATLog.log("[AnyThink] AndroidX EnableProperty" + EnableProperty); + // Enable AndroidX and Jetifier properties + gradlePropertiesUpdated.Add(PropertyAndroidX + EnableProperty); + gradlePropertiesUpdated.Add(PropertyJetifier + EnableProperty); +#endif + // Disable dexing using artifact transform (it causes issues for ExoPlayer with Gradle plugin 3.5.0+) + gradlePropertiesUpdated.Add(PropertyDexingArtifactTransform + DisableProperty); + + try + { + File.WriteAllText(gradlePropertiesPath, string.Join("\n", gradlePropertiesUpdated.ToArray()) + "\n"); + } + catch (Exception exception) + { + ATLog.logError("Failed to enable AndroidX and Jetifier. gradle.properties file write failed."); + Console.WriteLine(exception); + } + } + + private static void processAndroidManifest(string path) + { +#if UNITY_2019_3_OR_NEWER + var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml"); +#else + var manifestPath = Path.Combine(path, "unityLibrary/src/main/AndroidManifest.xml"); +#endif + // var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml"); + XDocument manifest; + try + { + manifest = XDocument.Load(manifestPath); + } +#pragma warning disable 0168 + catch (IOException exception) +#pragma warning restore 0168 + { + ATLog.log("[AnyThink] AndroidManifest.xml is missing."); + return; + } + + // Get the `manifest` element. + var elementManifest = manifest.Element("manifest"); + if (elementManifest == null) + { + ATLog.log("[AnyThink] AndroidManifest.xml is invalid."); + return; + } + + var elementApplication = elementManifest.Element("application"); + if (elementApplication == null) + { + ATLog.log("[AnyThink] AndroidManifest.xml is invalid."); + return; + } + + var metaDataElements = elementApplication.Descendants().Where(element => element.Name.LocalName.Equals("meta-data")); + addGoogleApplicationIdIfNeeded(elementApplication, metaDataElements); + // Save the updated manifest file. + manifest.Save(manifestPath); + } + + private static void addGoogleApplicationIdIfNeeded(XElement elementApplication, IEnumerable metaDataElements) + { + var googleApplicationIdMetaData = GetElementByName(metaDataElements, KeyMetaDataGoogleApplicationId); + + if (!ATConfig.isNetworkInstalledByName("Admob", ATConfig.OS_ANDROID)) + { + ATLog.log("addGoogleApplicationIdIfNeeded() >>> Admob not install."); +// if (googleApplicationIdMetaData != null) googleApplicationIdMetaData.Remove(); + return; + } + + var appId = ATConfig.getAdmobAppIdByOs(ATConfig.OS_ANDROID); + // Log error if the App ID is not set. + if (string.IsNullOrEmpty(appId) || !appId.StartsWith("ca-app-pub-")) + { + ATLog.logError("AdMob App ID is not set. Please enter a valid app ID within the ThinkupTpn Integration Manager window."); + return; + } + + // Check if the Google App ID meta data already exists. Update if it already exists. + if (googleApplicationIdMetaData != null) + { + googleApplicationIdMetaData.SetAttributeValue(AndroidNamespace + "value", appId); + } + // Meta data doesn't exist, add it. + else + { + elementApplication.Add(CreateMetaDataElement(KeyMetaDataGoogleApplicationId, appId)); + } + } + + /// + /// Looks through all the given meta-data elements to check if the required one exists. Returns null if it doesn't exist. + /// + private static XElement GetElementByName(IEnumerable elements, string name) + { + foreach (var element in elements) + { + var attributes = element.Attributes(); + if (attributes.Any(attribute => attribute.Name.Namespace.Equals(AndroidNamespace) + && attribute.Name.LocalName.Equals("name") + && attribute.Value.Equals(name))) + { + return element; + } + } + + return null; + } + + /// + /// Creates and returns a meta-data element with the given name and value. + /// + private static XElement CreateMetaDataElement(string name, object value) + { + var metaData = new XElement("meta-data"); + metaData.Add(new XAttribute(AndroidNamespace + "name", name)); + metaData.Add(new XAttribute(AndroidNamespace + "value", value)); + + return metaData; + } + + private static void processNetworkConfigXml(string path) + { + bool isChina = ATConfig.isSelectedChina(); + // bool isChina = true; + + //在application标签加上:android:networkSecurityConfig="@xml/thinkup_network_security_config" + addNetworkSecurityConfigInApplication(path, isChina); + +#if UNITY_2019_3_OR_NEWER + var resXmlPath = Path.Combine(path, "src/main/res/xml"); +#else + var resXmlPath = Path.Combine(path, "unityLibrary/src/main/res/xml"); +#endif + + var rexXmlDir = Path.Combine(resXmlPath, "thinkup_network_security_config.xml"); + if (File.Exists(rexXmlDir)) + { + if (!isChina) //海外不用配置这个xml + { + FileUtil.DeleteFileOrDirectory(rexXmlDir); + } + return; + } + if (!Directory.Exists(resXmlPath)) + { + Directory.CreateDirectory(resXmlPath); + } + + saveFile("Assets/ThinkupTpnPlugin/Script/Editor/thinkup_network_security_config.xml", resXmlPath); + } + + public static void saveFile(string filePathName , string toFilesPath) + { + FileInfo file = new FileInfo(filePathName); + string newFileName= file.Name; + file.CopyTo(toFilesPath + "/" + newFileName, true); + } + + private static void addNetworkSecurityConfigInApplication(string path, bool isChina) + { +#if UNITY_2019_3_OR_NEWER + var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml"); +#else + var manifestPath = Path.Combine(path, "unityLibrary/src/main/AndroidManifest.xml"); +#endif + // var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml"); + XDocument manifest; + try + { + manifest = XDocument.Load(manifestPath); + } +#pragma warning disable 0168 + catch (IOException exception) +#pragma warning restore 0168 + { + ATLog.log("[AnyThink] AndroidManifest.xml is missing."); + return; + } + + // Get the `manifest` element. + var elementManifest = manifest.Element("manifest"); + if (elementManifest == null) + { + ATLog.log("[AnyThink] AndroidManifest.xml is invalid."); + return; + } + + var elementApplication = elementManifest.Element("application"); + if (elementApplication == null) + { + ATLog.log("[AnyThink] AndroidManifest.xml is invalid."); + return; + } + //handle thinkup_network_security_config.xml + XAttribute networkConfigAttribute = elementApplication.Attribute(AndroidNamespace + "networkSecurityConfig"); + if (networkConfigAttribute != null) { + networkConfigAttribute.Remove(); + } + if (isChina) + { + elementApplication.Add(new XAttribute(AndroidNamespace + "networkSecurityConfig", "@xml/thinkup_network_security_config")); + } + + //这个设置主要是为了适配9.0以上的机器 + // + var usesLibraryElements = elementApplication.Descendants().Where(element => element.Name.LocalName.Equals("uses-library")); + if (usesLibraryElements == null) + { + elementApplication.Add(createHttpLegacyElement()); + } + else + { + XElement httpLegacyElement = GetElementByName(usesLibraryElements, "org.apache.http.legacy"); + if (httpLegacyElement == null) + { + elementApplication.Add(createHttpLegacyElement()); + } + } + manifest.Save(manifestPath); + } + + public static XElement createHttpLegacyElement() + { + var httpFeautre = new XElement("uses-library"); + httpFeautre.Add(new XAttribute(AndroidNamespace + "name", "org.apache.http.legacy")); + httpFeautre.Add(new XAttribute(AndroidNamespace + "required", "false")); + + return httpFeautre; + } + + private static XElement CreateMetaDataElement(string name, object value, object toolsNode) + { + var metaData = new XElement("meta-data"); + metaData.Add(new XAttribute(AndroidNamespace + "name", name)); + metaData.Add(new XAttribute(AndroidNamespace + "value", value)); + metaData.Add(new XAttribute(ToolsNamespace + "node", toolsNode)); + + return metaData; + } + } + +} + +#endif \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/Script/Editor/ATPostProcessBuildAndroid.cs.meta b/Assets/ThinkupTpnPlugin/Script/Editor/ATPostProcessBuildAndroid.cs.meta new file mode 100644 index 0000000..4199196 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/Editor/ATPostProcessBuildAndroid.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3d30cb65609fd445086cfca0ea470687 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/Editor/ATPostProcessBuildiOS.cs b/Assets/ThinkupTpnPlugin/Script/Editor/ATPostProcessBuildiOS.cs new file mode 100644 index 0000000..90dc16d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/Editor/ATPostProcessBuildiOS.cs @@ -0,0 +1,234 @@ +#if UNITY_IOS || UNITY_IPHONE + +using AnyThink.Scripts.IntegrationManager.Editor; +#if UNITY_2019_3_OR_NEWER +using UnityEditor.iOS.Xcode.Extensions; +#endif +using UnityEngine.Networking; +using System; +using System.Linq; +using System.Collections.Generic; +using System.IO; +using UnityEditor; +using UnityEditor.Callbacks; +using UnityEditor.iOS.Xcode; +using UnityEngine; + +namespace AnyThink.Scripts.Editor +{ + [Serializable] + public class SkAdNetworkData + { + [SerializeField] public string[] SkAdNetworkIds; + } + + public class TopOnPostProcessBuildiOS + { + private static string mBuildPath; + + private static readonly List AtsRequiringNetworks = new List + { + "AdColony", + "ByteDance", + "Fyber", + "Google", + "GoogleAdManager", + "HyprMX", + "InMobi", + "IronSource", + "Smaato" + }; + + private static List DynamicLibraryPathsToEmbed + { + get + { + var dynamicLibraryPathsToEmbed = new List(); + dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "KSAdSDK/KSAdSDK.xcframework")); + dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "StartAppSDK/StartApp.xcframework")); + dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "BigoADS/BigoADS/BigoADS.xcframework")); + dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "BigoADS/BigoADS/OMSDK_Bigosg.xcframework")); + dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "Fyber_Marketplace_SDK/IASDKCore/IASDKCore.xcframework")); + dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "InMobiSDK/InMobiSDK.xcframework")); + dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "GDTMobSDK/GDTFramework/GDTMobSDK.xcframework")); + dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "GDTMobSDK/GDTFramework/Tquic.xcframework")); + + //pubnative + dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "ATOM-Standalone/ATOM.xcframework")); + string pubNativePath = Path.Combine(mBuildPath, "Pods/HyBid/PubnativeLite/PubnativeLite"); + if (Directory.Exists(pubNativePath)) { + // 获取所有以"OMSDK-"开头的子目录 + string[] subDirectories = Directory.GetDirectories(pubNativePath, "OMSDK-*"); + if (subDirectories.Length > 0) { + string versionDirectory= subDirectories[0]; + string versionDirectoryName = Path.GetFileName(versionDirectory); + // ATLog.logError("DynamicLibraryPathsToEmbed() >>> pubNative versionDirectoryName: " + versionDirectoryName); + dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "HyBid/PubnativeLite/PubnativeLite/" + versionDirectoryName + "/OMSDK_Pubnativenet.xcframework")); + } + } + //applovin + string applovinPath = Path.Combine(mBuildPath, "Pods/AppLovinSDK"); + if (Directory.Exists(applovinPath)) { + // 获取所有以"applovin-ios-sdk-"开头的子目录 + string[] applovinSubDirectories = Directory.GetDirectories(applovinPath, "applovin-ios-sdk-*"); + if (applovinSubDirectories.Length > 0) { + string applovinVersionDirectory = applovinSubDirectories[0]; + string applovinVersionDirectoryName = Path.GetFileName(applovinVersionDirectory); + // ATLog.logError("DynamicLibraryPathsToEmbed() >>> applovinVersionDirectoryName: " + applovinVersionDirectoryName); + dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "AppLovinSDK/" + applovinVersionDirectoryName + "/AppLovinSDK.xcframework")); + } + } + + return dynamicLibraryPathsToEmbed; + } + } + + //读取本地已安装network的版本号:network_data.json + // private static string getNetworkVersion(string networkDataJsonFilePath) + // { + // if (!File.Exists(networkDataJsonFilePath)) { + // return ""; + // } + // string jsonData = File.ReadAllText(networkDataJsonFilePath); + // var networkLocalData = JsonUtility.FromJson(a_json); + // if (networkLocalData != null) { + // return networkLocalData.version; + // } + // retrun ""; + // } + + private static List BunldePathsToAdd { + get { + + var bunldePathsToAdd = new List(); + bunldePathsToAdd.Add(Path.Combine("Pods/", "BigoADS/BigoADS/BigoADSRes.bundle")); + bunldePathsToAdd.Add(Path.Combine("Pods/", "Ads-Global/SDK/PAGAdSDK.bundle")); + bunldePathsToAdd.Add(Path.Combine("Pods/", "Ads-CN/SDK/CSJAdSDK.bundle")); + bunldePathsToAdd.Add(Path.Combine("Pods/", "Ads-CN-Beta/SDK/CSJAdSDK.bundle")); + + return bunldePathsToAdd; + } + } + + private static readonly List SwiftLanguageNetworks = new List + { + "MoPub" + }; + + private static readonly List EmbedSwiftStandardLibrariesNetworks = new List + { + "Facebook", + "MoPub" + }; + + [PostProcessBuildAttribute(int.MaxValue)] + public static void TopOnPostProcessPbxProject(BuildTarget buildTarget, string buildPath) + { + var projectPath = PBXProject.GetPBXProjectPath(buildPath); + var project = new PBXProject(); + project.ReadFromFile(projectPath); + +#if UNITY_2019_3_OR_NEWER + var unityMainTargetGuid = project.GetUnityMainTargetGuid(); + var unityFrameworkTargetGuid = project.GetUnityFrameworkTargetGuid(); +#else + var unityMainTargetGuid = project.TargetGuidByName(UnityMainTargetName); + var unityFrameworkTargetGuid = project.TargetGuidByName(UnityMainTargetName); +#endif + + project.SetBuildProperty(unityMainTargetGuid, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES"); + project.SetBuildProperty(unityMainTargetGuid, "ENABLE_BITCODE", "NO"); + + project.SetBuildProperty(unityFrameworkTargetGuid, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES"); + project.SetBuildProperty(unityFrameworkTargetGuid, "ENABLE_BITCODE", "NO"); + + EmbedDynamicLibrariesIfNeeded(buildPath, project, unityMainTargetGuid); + AddBunleIfNeeded(buildPath, project, unityMainTargetGuid); + + project.WriteToFile(projectPath); + } + + [PostProcessBuildAttribute(int.MaxValue)] + public static void TopOnPostProcessPlist(BuildTarget buildTarget, string path) + { + var plistPath = Path.Combine(path, "Info.plist"); + var plist = new PlistDocument(); + plist.ReadFromFile(plistPath); + +#if UNITY_2018_2_OR_NEWER + AddGoogleApplicationIdIfNeeded(plist); +#endif + + plist.WriteToFile(plistPath); + } + + private static void AddBunleIfNeeded(string buildPath, PBXProject project, string targetGuid) + { + var bunldePathsPresentInProject = BunldePathsToAdd.Where(bunldePath => Directory.Exists(Path.Combine(buildPath, bunldePath))).ToList(); + if (bunldePathsPresentInProject.Count <= 0) return; + ATLog.log("AddBunleIfNeeded"); + +#if UNITY_2019_3_OR_NEWER + foreach (var bunldePath in bunldePathsPresentInProject) + { + var fileGuid = project.AddFile(bunldePath, bunldePath, PBXSourceTree.Source); + project.AddFileToBuild(targetGuid, fileGuid); + } +#endif + } + + private static void EmbedDynamicLibrariesIfNeeded(string buildPath, PBXProject project, string targetGuid) + { + mBuildPath = buildPath; + ATLog.log("EmbedDynamicLibrariesIfNeeded() >>> buildPath: " + buildPath); + var dynamicLibraryPathsPresentInProject = DynamicLibraryPathsToEmbed.Where(dynamicLibraryPath => Directory.Exists(Path.Combine(buildPath, dynamicLibraryPath))).ToList(); + if (dynamicLibraryPathsPresentInProject.Count <= 0) return; + +#if UNITY_2019_3_OR_NEWER + foreach (var dynamicLibraryPath in dynamicLibraryPathsPresentInProject) + { + var fileGuid = project.AddFile(dynamicLibraryPath, dynamicLibraryPath); + project.AddFileToEmbedFrameworks(targetGuid, fileGuid); + } +#else + string runpathSearchPaths; +#if UNITY_2018_2_OR_NEWER + runpathSearchPaths = project.GetBuildPropertyForAnyConfig(targetGuid, "LD_RUNPATH_SEARCH_PATHS"); +#else + runpathSearchPaths = "$(inherited)"; +#endif + runpathSearchPaths += string.IsNullOrEmpty(runpathSearchPaths) ? "" : " "; + + // Check if runtime search paths already contains the required search paths for dynamic libraries. + if (runpathSearchPaths.Contains("@executable_path/Frameworks")) return; + + runpathSearchPaths += "@executable_path/Frameworks"; + project.SetBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", runpathSearchPaths); +#endif + } + +#if UNITY_2018_2_OR_NEWER + + private static void AddGoogleApplicationIdIfNeeded(PlistDocument plist) + { + if (!ATConfig.isNetworkInstalledByName("Admob", ATConfig.OS_IOS)) + { + ATLog.log("addGoogleApplicationIdIfNeeded() >>> Admob not install."); + return; + } + //获取admob app id + var appId = ATConfig.getAdmobAppIdByOs(ATConfig.OS_IOS); + + if (string.IsNullOrEmpty(appId) || !appId.StartsWith("ca-app-pub-")) + { + ATLog.logError("AdMob App ID is not set. Please enter a valid app ID within the ThinkupTpn Integration Manager window."); + return; + } + + const string googleApplicationIdentifier = "GADApplicationIdentifier"; + plist.root.SetString(googleApplicationIdentifier, appId); + } +#endif + } +} +#endif diff --git a/Assets/ThinkupTpnPlugin/Script/Editor/ATPostProcessBuildiOS.cs.meta b/Assets/ThinkupTpnPlugin/Script/Editor/ATPostProcessBuildiOS.cs.meta new file mode 100644 index 0000000..b8c83f4 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/Editor/ATPostProcessBuildiOS.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 88e0e347ecf5f4877b7026a0b60b5df0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/Editor/ATProcessBuildGradleAndroid.cs b/Assets/ThinkupTpnPlugin/Script/Editor/ATProcessBuildGradleAndroid.cs new file mode 100644 index 0000000..f1bb8a3 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/Editor/ATProcessBuildGradleAndroid.cs @@ -0,0 +1,354 @@ +#if UNITY_ANDROID && UNITY_2018_2_OR_NEWER +using AnyThink.Scripts.IntegrationManager.Editor; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Xml.Linq; +using UnityEditor; +using UnityEditor.Android; +using System.Text.RegularExpressions; +using System.Diagnostics; +using UnityEngine; +using System.Text; + + +namespace AnyThink.Scripts.Editor +{ + + public class ATProcessBuildGradleAndroid + { + + // public void OnPostGenerateGradleAndroidProject(string path) + // { + + // } + + public static void processBuildGradle(string path) + { +#if UNITY_2019_3_OR_NEWER + var buildGradlePath = Path.Combine(path, "../build.gradle"); +#else + var buildGradlePath = Path.Combine(path, "build.gradle"); +#endif + +#if UNITY_2022_1_OR_NEWER + ATLog.log("processBuildGradle() >>> called"); +#else + replaceBuildPluginVersion(buildGradlePath); + // replaceAppBuildPluginVersion(path); +#endif + // replaceAppBuildPluginVersion(path); + handleNetworksConfit(path); + // handleNetworkResMerge(path); + // callGradleTask(path); + } + //修改项目的根目录下的build.gradle文件的插件版本号 + private static void replaceBuildPluginVersion(string buildGradlePath) + { + if (!File.Exists(buildGradlePath)) + { + return; + } + string gradleFileContent = ""; + using (StreamReader reader = new StreamReader(buildGradlePath)) + { + gradleFileContent = reader.ReadToEnd(); + } + if (string.IsNullOrEmpty(gradleFileContent)) + { + return; + } + + string buildGradleVersion = ""; + string buildGradlePattern = ""; + + string buildGradleVersion3 = "3.3.3"; // 新gradle插件版本号 + string buildGradlePattern3 = @"(?<=gradle:)3\.3\.\d+"; + string buildGradleVersion4 = "3.4.3"; + string buildGradlePattern4 = @"(?<=gradle:)3\.4\.\d+"; + string buildGradleVersion5 = "3.5.4"; + string buildGradlePattern5 = @"(?<=gradle:)3\.5\.\d+"; + string buildGradleVersion6 = "3.6.4"; + string buildGradlePattern6 = @"(?<=gradle:)3\.6\.\d+"; + + if (isMatchGradleVersion(gradleFileContent, buildGradleVersion3)) + { + buildGradleVersion = buildGradleVersion3; + buildGradlePattern = buildGradlePattern3; + } + else if(isMatchGradleVersion(gradleFileContent, buildGradleVersion4)) + { + buildGradleVersion = buildGradleVersion4; + buildGradlePattern = buildGradlePattern4; + } + else if(isMatchGradleVersion(gradleFileContent, buildGradleVersion5)) + { + buildGradleVersion = buildGradleVersion5; + buildGradlePattern = buildGradlePattern5; + } + else if(isMatchGradleVersion(gradleFileContent, buildGradleVersion6)) + { + buildGradleVersion = buildGradleVersion6; + buildGradlePattern = buildGradlePattern6; + } + + if (!string.IsNullOrEmpty(buildGradlePattern) && !string.IsNullOrEmpty(buildGradleVersion)) + { + replaceContent(buildGradlePath, buildGradlePattern, buildGradleVersion); + } + } + + private static void replaceContent(string filePath, string pattern, string content) + { + if (!File.Exists(filePath)) + { + return; + } + string buildGradle = ""; + using (StreamReader reader = new StreamReader(filePath)) + { + buildGradle = reader.ReadToEnd(); + } + // Regex regex = new Regex(pattern); + buildGradle = Regex.Replace(buildGradle, pattern, content); + + // 修改gradle-wrapper版本号 + // string oldWrapperVersion = "distributionUrl=https\\://services.gradle.org/d + using (StreamWriter writer = new StreamWriter(filePath)) + { + writer.Write(buildGradle); + } + } + + private static bool isMatchGradleVersion(string gradleFileContent, string version) + { + string matchStr = String.Format("gradle:{0}", version.Substring(0, 3)); + return gradleFileContent.Contains(matchStr); + } + //修改app module下的build.gradle + private static void replaceAppBuildPluginVersion(string path) + { +#if UNITY_2019_3_OR_NEWER + var buildGradlePath = Path.Combine(path, "../launcher/build.gradle"); +#else + var buildGradlePath = Path.Combine(path, "launcher/build.gradle"); +#endif + if (!File.Exists(buildGradlePath)) + { + return; + } + string buildGradleVersion = "30"; + string compileSdkVersionPattern = "compileSdkVersion"; + string targetSdkVersionPattern = "targetSdkVersion"; + + List lines = new List(); + using (StreamReader reader = new StreamReader(buildGradlePath)) + { + string line; + while ((line = reader.ReadLine()) != null) + { + lines.Add(line); + } + } + int indexToReplace = -1; + int indexToReplace1 = -1; + int removeIndex = -1; + int addIndex = -1; + for (int i = 0; i < lines.Count; i++) + { + if (lines[i].Contains(compileSdkVersionPattern)) + { + indexToReplace = i; + } + else if (lines[i].Contains(targetSdkVersionPattern)) + { + indexToReplace1 = i; + } + else if (lines[i].Contains("buildToolsVersion")) + { + removeIndex = i; + } + else if (lines[i].Contains("defaultConfig")) + { + addIndex = i; + } + } + if (indexToReplace != -1) + { + lines[indexToReplace] = " " + compileSdkVersionPattern + " " + buildGradleVersion; + } + if (indexToReplace1 != -1) + { + lines[indexToReplace1] = " " + targetSdkVersionPattern + " " + buildGradleVersion; + } + if (removeIndex != -1) + { + lines.RemoveAt(removeIndex); + } + if (addIndex != -1) + { + lines.Insert(addIndex + 1, " multiDexEnabled true"); + } + using (StreamWriter writer = new StreamWriter(buildGradlePath)) + { + foreach (string line in lines) + { + writer.WriteLine(line); + } + } + } + + private static void handleNetworksConfit(string path) + { + if (ATConfig.isSelectedChina()) + { + return; + } +#if UNITY_2019_3_OR_NEWER + var buildGradlePath = Path.Combine(path, "../launcher/build.gradle"); +#else + var buildGradlePath = Path.Combine(path, "launcher/build.gradle"); +#endif + if (!File.Exists(buildGradlePath)) + { + return; + } + List lines = new List(); + using (StreamReader reader = new StreamReader(buildGradlePath)) + { + string line; + while ((line = reader.ReadLine()) != null) + { + lines.Add(line); + } + } + var androidStartIndex = 0; + var isConfigAll = false; + var isExcludeModule = false; + + for (int i = 0; i < lines.Count; i++) + { + if (lines[i].Contains("android {")) + { + androidStartIndex = i; + } + else if (lines[i].Contains("configurations.all")) + { + isConfigAll = true; + } + else if (lines[i].Contains("META-INF/*.kotlin_module")) + { + isExcludeModule = true; + } + } + if (androidStartIndex > 0) + { + if (!isExcludeModule) + { + lines.Insert(androidStartIndex + 1, " packagingOptions {\n merge 'META-INF/com.android.tools/proguard/coroutines.pro'\n exclude 'META-INF/*.kotlin_module'\n }"); + } + // if (!isConfigAll) + // { + // lines.Insert(androidStartIndex -1, "configurations.all {\n resolutionStrategy {\n force 'androidx.core:core:1.6.0'\n force 'androidx.recyclerview:recyclerview:1.1.0' \n }\n}"); + // } + } + // configurations.all { + // resolutionStrategy { + // force 'androidx.core:core:1.6.0' + // force 'androidx.recyclerview:recyclerview:1.1.0' + // } + // } + // packagingOptions { + // merge "META-INF/com.android.tools/proguard/coroutines.pro" + // exclude "META-INF/*.kotlin_module" + // } + using (StreamWriter writer = new StreamWriter(buildGradlePath)) + { + foreach (string line in lines) + { + writer.WriteLine(line); + } + } + } + + private static void handleNetworkResMerge(string path) { + ATLog.log("handleNetworkResMerge() >>> path: " + path); +#if UNITY_2019_3_OR_NEWER + var buildGradlePath = Path.Combine(path, "../launcher/build.gradle"); +#else + var buildGradlePath = Path.Combine(path, "launcher/build.gradle"); +#endif + List lines = new List(); + bool isAdded = false; + + using (StreamReader reader = new StreamReader(buildGradlePath)) + { + string line; + while ((line = reader.ReadLine()) != null) + { + if (line.Contains("task handleNetworkResMerge")) { + isAdded = true; + } + lines.Add(line); + } + } + if (isAdded) { + return; + } + using (StreamReader reader = new StreamReader("Assets/ThinkupTpnPlugin/Script/Editor/network_res_handle.gradle")) + { + string line; + while ((line = reader.ReadLine()) != null) + { + lines.Add(line); + } + } + using (StreamWriter writer = new StreamWriter(buildGradlePath)) + { + foreach (string line in lines) + { + writer.WriteLine(line); + } + } + } + + private static void callGradleTask(string path) { + // 设置你想要启动的Gradle任务 + string gradleTask = "handleNetworkResMerge"; // 例如: assembleDebug or assembleRelease + + // 开始一个新的进程来执行Gradle任务 + ProcessStartInfo psi = new ProcessStartInfo(); + psi.FileName = Application.platform == RuntimePlatform.WindowsEditor ? "cmd" : "bash"; + psi.Arguments = Application.platform == RuntimePlatform.WindowsEditor ? + $"/c gradlew {gradleTask}" : // Windows cmd命令 + $"-c './gradlew {gradleTask}'"; // UNIX bash命令 + psi.UseShellExecute = false; + psi.StandardOutputEncoding = Encoding.UTF8; + psi.StandardErrorEncoding = Encoding.UTF8; + psi.RedirectStandardOutput = true; + psi.RedirectStandardError = true; + psi.CreateNoWindow = true; + psi.WorkingDirectory = "/Users/quinx/Desktop/workspace_topon/sdk_source/a_unity_demo/TestAnyThinkUnityPlugin/Library/Bee/Android/Prj/Mono2x/Gradle"; // 这里应该是你的Android项目路径 + + ATLog.log("callGradleTask() >>> path: " + path); + + using (var process = Process.Start(psi)) + { + // 读取输出信息 + while (!process.StandardOutput.EndOfStream) + { + var line = process.StandardOutput.ReadLine(); + UnityEngine.Debug.Log(line); + } + // 读取错误信息 + while (!process.StandardError.EndOfStream) + { + var line = process.StandardError.ReadLine(); + UnityEngine.Debug.LogError(line); + } + } + } + } +} +#endif \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/Script/Editor/ATProcessBuildGradleAndroid.cs.meta b/Assets/ThinkupTpnPlugin/Script/Editor/ATProcessBuildGradleAndroid.cs.meta new file mode 100644 index 0000000..da0fdf3 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/Editor/ATProcessBuildGradleAndroid.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d3925945c0f174bbc9ab7416ffdea740 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/Editor/AnyThinkPlugin.Script.Editor.asmdef b/Assets/ThinkupTpnPlugin/Script/Editor/AnyThinkPlugin.Script.Editor.asmdef new file mode 100644 index 0000000..331dd52 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/Editor/AnyThinkPlugin.Script.Editor.asmdef @@ -0,0 +1,11 @@ +{ + "name": "ThinkupTpnPlugin.Script.Editor", + "references": [ + "ThinkupTpnPlugin.Script", + "ThinkupTpnPlugin.Script.IntegrationManager.Editor" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [] +} diff --git a/Assets/ThinkupTpnPlugin/Script/Editor/AnyThinkPlugin.Script.Editor.asmdef.meta b/Assets/ThinkupTpnPlugin/Script/Editor/AnyThinkPlugin.Script.Editor.asmdef.meta new file mode 100644 index 0000000..2867b7c --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/Editor/AnyThinkPlugin.Script.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d10a15b402251482baa74f15d62ace18 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/Editor/thinkup_network_security_config.xml b/Assets/ThinkupTpnPlugin/Script/Editor/thinkup_network_security_config.xml new file mode 100644 index 0000000..2439f15 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/Editor/thinkup_network_security_config.xml @@ -0,0 +1,4 @@ + + + + diff --git a/Assets/ThinkupTpnPlugin/Script/Editor/thinkup_network_security_config.xml.meta b/Assets/ThinkupTpnPlugin/Script/Editor/thinkup_network_security_config.xml.meta new file mode 100644 index 0000000..2cb69b8 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/Editor/thinkup_network_security_config.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4fc4403e7d19747f1abcdbbb71c650c4 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager.meta new file mode 100644 index 0000000..9898a2d --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 640fa4d43e21e4910916921b53d110ad +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor.meta new file mode 100644 index 0000000..cdb9cf7 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e911636ac126b4819bb8ee84eecfac04 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATAssetPostprocessor.cs b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATAssetPostprocessor.cs new file mode 100644 index 0000000..414812a --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATAssetPostprocessor.cs @@ -0,0 +1,47 @@ +using System; +using UnityEditor; +using UnityEngine; +using AnyThink.Scripts.IntegrationManager.Editor; + +[InitializeOnLoad] +public class ATAssetPostprocessor : AssetPostprocessor +{ + private static readonly string TAG = "ATAssetPostprocessor"; + + static ATAssetPostprocessor() + { + log("ATAssetPostprocessor is now initialized!"); + } + void OnPostprocessAsset(string path) + { + log("OnPostprocessAsset() >>> path: " + path + " assetPath: " + assetPath); + } + + static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) + { + foreach (string str in importedAssets) + { + log("imported Asset: " + str); + } + foreach (string str in deletedAssets) + { + log("Deleted Asset: " + str); + } + + for (int i = 0; i < movedAssets.Length; i++) + { + log("Moved Asset: " + movedAssets[i] + " from: " + movedFromAssetPaths[i]); + } + + } + + void OnPreprocessAsset() + { + log("OnPreprocessAsset() >>> called assetPath: " + assetPath); + } + + private static void log(string msg) + { + ATLog.log(TAG, msg); + } +} diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATAssetPostprocessor.cs.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATAssetPostprocessor.cs.meta new file mode 100644 index 0000000..9f807f2 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATAssetPostprocessor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f9137cd99292b497cbba1a142f7e73ee +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATConfig.cs b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATConfig.cs new file mode 100644 index 0000000..178db48 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATConfig.cs @@ -0,0 +1,426 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Xml.Linq; +using UnityEditor; +using UnityEngine; +using UnityEngine.Networking; +// using AnyThink.Scripts.Assets; +using System.Text.RegularExpressions; + +namespace AnyThink.Scripts.IntegrationManager.Editor +{ + + public class ATConfig + { +public static string PLUGIN_VERSION = "2.1.5"; +public static bool isDebug = false; + + public static int PLUGIN_TYPE = 2; + public static int OS_ANDROID = 1; + public static int OS_IOS = 2; + public static int CHINA_COUNTRY = 1; + public static int NONCHINA_COUNTRY = 2; + public static string ANYTHINK_SDK_FILES_PATH = "Assets/ThinkupTpnPlugin/AnyThinkAds"; + //国内Android core包的相关目录 + public static string[] CHINA_ANDROID_CORE_FILES_ARRAY = {Path.Combine(ANYTHINK_SDK_FILES_PATH, "Plugins/Android/China/Editor"), + Path.Combine(ANYTHINK_SDK_FILES_PATH, "Plugins/Android/China/thinkup_base"), + Path.Combine(ANYTHINK_SDK_FILES_PATH, "Plugins/Android/China/mediation_plugin")}; + //海外Android core包的相关目录 + public static string[] NON_CHINA_ANDROID_CORE_FILES_ARRAY = {Path.Combine(ANYTHINK_SDK_FILES_PATH, "Plugins/Android/NonChina/thinkup_base"), + Path.Combine(ANYTHINK_SDK_FILES_PATH, "Plugins/Android/NonChina/Editor")}; + + //国内core aar包的父目录 + public static string CHINA_ANDROID_CORE_FILES_PATH = Path.Combine(ANYTHINK_SDK_FILES_PATH, "Plugins/Android/China/thinkup_base/"); + public static string NONCHINA_ANDROID_CORE_FILES_PATH = Path.Combine(ANYTHINK_SDK_FILES_PATH, "Plugins/Android/NonChina/thinkup_base/"); + //国内Android network aar包的父目录 + public static string CHINA_ANDROID_NETWORK_FILES_PARENT_PATH = Path.Combine(ANYTHINK_SDK_FILES_PATH, "Plugins/Android/China/mediation/"); + //海外Android network 依赖文件的目录 + public static string NONCHINA_ANDROID_NETWORK_FILES_PARENT_PATH = Path.Combine(ANYTHINK_SDK_FILES_PATH, "Plugins/Android/NonChina/mediation/"); + //iOS network依赖文件的目录,不区分国家 + public static string IOS_NETWORK_FILES_PARENT_PATH = Path.Combine(ANYTHINK_SDK_FILES_PATH, "Plugins/iOS/China/"); + public static string NONCHINA_IOS_NETWORK_FILES_PARENT_PATH = Path.Combine(ANYTHINK_SDK_FILES_PATH, "Plugins/iOS/NonChina/"); + //network json文件名 + public static string network_data_file_name = "network_data.json"; + //插件设置的数据 + public static string plugin_setting_data_path = "Assets/ThinkupTpnPlugin/Resources/json/" + PLUGIN_VERSION; + private static string plugin_setting_data_file_name = "plugin_setting_data.json"; + + //保存插件设置的数据,保存时机:安装core包、选择国家、切换SDK、androidX设置发生变化时 + public static void savePluginSettingData(PluginSettingData settingData) + { + var directoryPath = plugin_setting_data_path; + // 确保目标文件夹存在 + if (!Directory.Exists(directoryPath)) + { + // 如果目录不存在,则创建它 + Directory.CreateDirectory(directoryPath); + } + string fullPath = Path.Combine(directoryPath, plugin_setting_data_file_name); + string settingDataStr = JsonUtility.ToJson(settingData); + ATLog.log("savePluginSettingData() >>> fullPath: " + fullPath + " settingDataStr: " + settingDataStr); + File.WriteAllText(fullPath, settingDataStr); + } + //获取插件设置的数据 + public static PluginSettingData getPluginSettingData() + { + string fullPath = Path.Combine(plugin_setting_data_path, plugin_setting_data_file_name); + if (!File.Exists(fullPath)) { + return null; + } + string json = File.ReadAllText(fullPath); + if(json == "") { + return null; + } + return JsonUtility.FromJson(json); + } + + public static bool removeSdk(int country, int os) { + string path = ANYTHINK_SDK_FILES_PATH + "/Plugins"; + if (os == OS_ANDROID) { + path = path + "/Android"; + } else { + path = path + "/iOS"; + } + if (country == CHINA_COUNTRY) { + path = path + "/China"; + } else { + path = path + "/NonChina"; + } + if (Directory.Exists(path)) { + FileUtil.DeleteFileOrDirectory(path); + } + if (File.Exists(path + ".meta")) { + FileUtil.DeleteFileOrDirectory(path + ".meta"); + } + return true; + } + + //移除本地的network + public static bool removeInstalledNetwork(Network network, int os) + { + //修改sdk的配置 + if (isCoreNetwork(network.Name) && os == OS_ANDROID) { + var paths = CHINA_ANDROID_CORE_FILES_ARRAY; + if (network.Country == NONCHINA_COUNTRY) { + paths = NON_CHINA_ANDROID_CORE_FILES_ARRAY; + } + foreach(string p in paths) { + if (Directory.Exists(p)) { + FileUtil.DeleteFileOrDirectory(p); + } + if (File.Exists(p + ".meta")) { + FileUtil.DeleteFileOrDirectory(p + ".meta"); + } + } + return true; + } + var path = getAndroidNetworkPath(network); + if (os == OS_IOS) { + path = getIosNetworkPath(network); + } + if (Directory.Exists(path)) { + FileUtil.DeleteFileOrDirectory(path); + if (File.Exists(path + ".meta")) { + FileUtil.DeleteFileOrDirectory(path + ".meta"); + } + } + //针对mintegral改名字为gtm后,旧版升级到新版,旧版的mintegral目录需要删除 + var displayName = network.DisplayName; + var name = network.Name; + ATLog.log("removeInstalledNetwork() >>> displayName: " + displayName + " name: " + name); + if (Equals(displayName, "Mintegral") && Equals(name, "Gtm")) + { + displayName = "mintegral"; + var mtgPath = getNetworkInstallPath(displayName, os, network.Country); + if (Directory.Exists(mtgPath)) + { + FileUtil.DeleteFileOrDirectory(mtgPath); + if (File.Exists(mtgPath + ".meta")) + { + FileUtil.DeleteFileOrDirectory(mtgPath + ".meta"); + } + } + } + return true; + } + + // 保存已安装的network到本地 + public static void saveInstalledNetworkVersion(Network network, int os) + { + if (isCoreNetwork(network.Name)) { + return; + } + var networkDataFileName = network_data_file_name; + var networkName = network.Name.ToLower(); + int country = network.Country; + var installedVersions = network.CurrentVersions; + if (installedVersions != null) { + if (os == OS_ANDROID) { + var android_version = installedVersions.Android; + //Android + if (!string.IsNullOrEmpty(android_version)) { + var networkPath = getAndroidNetworkPath(network); + Directory.CreateDirectory(networkPath); + ATLog.log("saveInstalledNetworkVersion() >>> android networkPath: " + networkPath + " exist: " + Directory.Exists(networkPath)); + if (Directory.Exists(networkPath)) { + string fullPath = Path.Combine(networkPath, networkDataFileName); + var networkData = new NetworkLocalData(); + networkData.name = networkName; + networkData.country = country; + networkData.version = android_version; + networkData.path = networkPath; + + File.WriteAllText(fullPath, JsonUtility.ToJson(networkData)); + } + } + } else { + //iOS + var ios_version = installedVersions.Ios; + if (!string.IsNullOrEmpty(ios_version)) { + var networkPath = getIosNetworkPath(network); + Directory.CreateDirectory(networkPath); + ATLog.log("saveInstalledNetworkVersion() >>> ios networkPath: " + networkPath); + if (Directory.Exists(networkPath)) { + string fullPath = Path.Combine(networkPath, networkDataFileName); + var networkData = new NetworkLocalData(); + networkData.name = networkName; + networkData.country = country; + networkData.version = ios_version; + networkData.path = networkPath; + + File.WriteAllText(fullPath, JsonUtility.ToJson(networkData)); + } + } + } + } + } + + //Core 是否已安装 + public static bool isCoreNetworkInstalled(PluginSettingData pluginSettingData, int os) { + var countrySettingData = pluginSettingData.getCountrySettingData(); + if (os == OS_ANDROID) { + return !string.IsNullOrEmpty(countrySettingData.android_version); + } else { + return !string.IsNullOrEmpty(countrySettingData.ios_version); + } + } + + //Network是否已安装 + public static bool isNetworkInstalled(Network network, int os) + { + if (isCoreNetwork(network.Name)) { + var pluginSettingData = getPluginSettingData(); + return isCoreNetworkInstalled(pluginSettingData, os); + } + var path = getIosNetworkPath(network); + if (os == OS_ANDROID) { + path = getAndroidNetworkPath(network); + } + return File.Exists(Path.Combine(path, network_data_file_name)); + } + + //Network是否已安装,根据name + public static bool isNetworkInstalledByName(string name, int os) + { + var pluginSettingData = getPluginSettingData(); + if (pluginSettingData != null) { + var country = pluginSettingData.curCountry; + var network = new Network(); + network.Name = name; + network.Country = country; + return isNetworkInstalled(network, os); + } + return false; + } + + private static string getAndroidNetworkPath(Network network) + { + var networkName = network.Name.ToLower(); + var country = network.Country; + if (isCoreNetwork(networkName)) + { + return country == CHINA_COUNTRY ? CHINA_ANDROID_CORE_FILES_PATH : NONCHINA_ANDROID_CORE_FILES_PATH; + } + else + { + return country == CHINA_COUNTRY ? CHINA_ANDROID_NETWORK_FILES_PARENT_PATH + networkName.ToLower() : NONCHINA_ANDROID_NETWORK_FILES_PARENT_PATH + networkName.ToLower(); + } + } + + private static string getIosNetworkPath(Network network) + { + var networkName = network.Name.ToLower(); + var country = network.Country; + // if (isCoreNetwork(networkName)) + // { + // return IOS_NETWORK_FILES_PARENT_PATH; + // } else { + // } + return country == CHINA_COUNTRY ? IOS_NETWORK_FILES_PARENT_PATH + networkName : NONCHINA_IOS_NETWORK_FILES_PARENT_PATH + networkName; + } + + //根据network名字去获取安装路径 + private static string getNetworkInstallPath(string networkName, int os, int country) + { + if (os == OS_ANDROID) { + return country == CHINA_COUNTRY ? CHINA_ANDROID_NETWORK_FILES_PARENT_PATH + networkName.ToLower() : NONCHINA_ANDROID_NETWORK_FILES_PARENT_PATH + networkName.ToLower(); + } else { + return country == CHINA_COUNTRY ? IOS_NETWORK_FILES_PARENT_PATH + networkName : NONCHINA_IOS_NETWORK_FILES_PARENT_PATH + networkName; + } + } + + + public static int getSelectedCountry() + { + var pluginSettingData = getPluginSettingData(); + if (pluginSettingData != null) + { + return pluginSettingData.curCountry; + } + return CHINA_COUNTRY; + } + + + public static bool isCoreNetwork(string networkName) { + return Equals(networkName.ToLower(), ATIntegrationManager.AnyThinkNetworkName.ToLower()); + } + + //查找本地是否有已安装network,并进行版本赋值 + public static void initNetworkLocalData(Network network) { + var networkDataFileName = network_data_file_name; + var androidPath = getAndroidNetworkPath(network); + var iosPath = getIosNetworkPath(network); + + var androidDataFile = Path.Combine(androidPath, networkDataFileName); + var iosDataFile = Path.Combine(iosPath, networkDataFileName); + + var curVersions = network.CurrentVersions; + if (curVersions == null) { + curVersions = new Versions(); + } + + if (File.Exists(androidDataFile)) { + string a_json = File.ReadAllText(androidDataFile); + var a_data = JsonUtility.FromJson(a_json); + curVersions.Android = a_data.version; + } + + if (File.Exists(iosDataFile)) { + string i_json = File.ReadAllText(iosDataFile); + var i_data = JsonUtility.FromJson(i_json); + curVersions.Ios = i_data.version; + } + network.CurrentVersions = curVersions; + } + + //当前是否选择国内地区 + public static bool isSelectedChina() { + var pluginSettingData = getPluginSettingData(); + if (pluginSettingData != null) { + return pluginSettingData.curCountry == CHINA_COUNTRY; + } + return true; + } + + //获取admob app id + public static string getAdmobAppIdByOs(int os) { + var pluginSettingData = getPluginSettingData(); + if (pluginSettingData == null) { + return ""; + } + var settingData = pluginSettingData.getCountrySettingData(); + return settingData.getAdmobAppId(os); + } + + public static bool enableAndroidX() { + var pluginSettingData = getPluginSettingData(); + if (pluginSettingData == null) { + return false; + } + return pluginSettingData.getCountrySettingData().androidXSetting == 1; + } + + public static bool isDefaultAndroidX() { + var pluginSettingData = getPluginSettingData(); + if (pluginSettingData == null) { + return false; + } + return pluginSettingData.getCountrySettingData().androidXSetting == 0; + } + + //获取默认选中的地区 + public static int getDefCountry() { + // string version = PLUGIN_VERSION; + // int lastIndex = version.LastIndexOf('.'); + + // if (lastIndex != -1) + // { + // //2.1.0:是区分国内海外的插件,2.1.01:后缀多了1,是只有海外的插件 + // string lastPart = version.Substring(lastIndex + 1); + // if (lastPart.Length == 2) { + // return NONCHINA_COUNTRY; + // } + // } + if(PLUGIN_TYPE == 2) { + return NONCHINA_COUNTRY; + } + return CHINA_COUNTRY; + } + + public static string[] getCountryArray() { + // new string[] { "ChinaMainland", "Overseas" } + // string version = PLUGIN_VERSION; + // int lastIndex = version.LastIndexOf('.'); + + // if (lastIndex != -1) + // { + // //2.1.0:是区分国内海外的插件,2.1.01:后缀多了1,是只有海外的插件 + // string lastPart = version.Substring(lastIndex + 1); + // if (lastPart.Length == 2) { + // return new string[] { "Overseas" }; + // } + // } + if(PLUGIN_TYPE == 2) { + return new string[] { "Overseas" }; + } + return new string[] { "ChinaMainland", "Overseas" }; + } + + public static string getRegionIntegrateTip() + { + //Tips: If ChinaMainland and Oversea are integrated at the same time, there will be compilation conflicts, whether it is Android or iOS platform. + //Currently, the Android platform integrates ChinaMainland and Oversea at the same time, which may cause compilation errors or other errors. + var pluginSettingData = getPluginSettingData(); + if (pluginSettingData == null) { + return ""; + } + var sb = new StringBuilder(); + sb.Append("Tips: Currently, "); + var android_tip = false; + if (pluginSettingData.isBothInstallAndroid()) { + sb.Append("the Android platform "); + android_tip = true; + } + var ios_tip = false; + if (pluginSettingData.isBothInstallIOS()) { + if (android_tip) { + sb.Append("and "); + } + sb.Append("iOS platform "); + ios_tip = true; + } + + if (android_tip || ios_tip) { + sb.Append("integrates ChinaMainland and Oversea at the same time, which may cause compilation error or other errors."); + return sb.ToString(); + } else { + return ""; + } + } + } + +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATConfig.cs.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATConfig.cs.meta new file mode 100644 index 0000000..62da12e --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATConfig.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2b2352e251db34ef68de45cc12f61ccf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATDataUtil.cs b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATDataUtil.cs new file mode 100644 index 0000000..403618b --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATDataUtil.cs @@ -0,0 +1,355 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Xml.Linq; +using UnityEditor; +using UnityEngine; +using UnityEngine.Networking; + +namespace AnyThink.Scripts.IntegrationManager.Editor +{ + public class ATDataUtil + { + + public static Network coreNetwork; + + public static Network[] parseNetworksJson(PluginData pluginData, string netowrksJson) + { + try + { + int country = pluginData.country; + bool isChinaCountry = isChina(country); + + ServerNetworks serverNetworks = JsonUtility.FromJson(netowrksJson); + + Network network = pluginData.anyThink; + if (network == null) { + return null; + } + var android_version = pluginData.requestParams.androidVersion; + var ios_version = pluginData.requestParams.iosVersion; + + var androidSdkVersionList = serverNetworks.android_sdk; + var iosSdkVersionList = serverNetworks.ios_sdk; + + ServerNetworkSdk androidNeworkSdk = null; + if (!string.IsNullOrEmpty(android_version)) { + foreach(ServerNetworkSdk sdk in androidSdkVersionList) { + if (Equals(sdk.version, android_version)) { + androidNeworkSdk = sdk; + } + } + } + + ServerNetworkSdk iosNeworkSdk = null; + if (!string.IsNullOrEmpty(ios_version)) { + foreach(ServerNetworkSdk sdk in iosSdkVersionList) { + if (Equals(sdk.version, ios_version)) { + iosNeworkSdk = sdk; + } + } + } + ATLog.log("parseNetworksJson() >>> androidNeworkSdk: " + androidNeworkSdk + " iosNeworkSdk: " + iosNeworkSdk); + + ServerNetworkInfo[] serverNetworkInfoList; + Network[] networks = mergeAndroidIosNetworks(getServerNetworkInfo(isChinaCountry, androidNeworkSdk, ATConfig.OS_ANDROID), getServerNetworkInfo(isChinaCountry, iosNeworkSdk, ATConfig.OS_IOS)); + Array.Sort(networks); + ATLog.log("parseNetworksJson() >>> networks.Length: " + networks.Length); + //处理本地已安装过的Core和Network数据 + var countrySettingData = pluginData.pluginSettingData.getCountrySettingData(); + + List networkList = new List(); + foreach(var item in networks) { + if (Equals(item.Name, ATIntegrationManager.AnyThinkNetworkName)) { + network.Name = item.Name; + network.DisplayName = item.DisplayName; + network.AndroidDownloadUrl = item.AndroidDownloadUrl; + network.iOSDownloadloadUrl = item.iOSDownloadloadUrl; + network.PluginFileName = item.PluginFileName; + //本地是否有安装core + var version = network.CurrentVersions; + if (version == null) { + version = new Versions(); + } + version.Android = countrySettingData.android_version; + version.Ios = countrySettingData.ios_version; + network.CurrentVersions = version; + network.LatestVersions = item.LatestVersions; + } else { + // ATLog.log("parseNetworksJson() >>> lastAndroidVersion: " + item.LatestVersions.Android + " lastIosVerion: " + item.LatestVersions.Ios); + //本地是否有安装network + ATConfig.initNetworkLocalData(item); + networkList.Add(item); + } + } + + return networkList.ToArray(); + } + catch (Exception e) + { + // 错误处理代码 + ATLog.log("parseNetworksJson() >>> failed: " + e); + } + + return null; + } + + public static PluginData parsePluginDataJson(string serverPluginVersionJson) + { + ATLog.log("parsePluginDataJson plugin version data: " + serverPluginVersionJson); + + try + { + var pluginData = new PluginData(); + + ServerPluginVersion serverPluginVersion = JsonUtility.FromJson(serverPluginVersionJson); + + pluginData.androidVersions = serverPluginVersion.android_versions; + pluginData.iosVersions = serverPluginVersion.ios_versions; + pluginData.pluginVersion = serverPluginVersion.pluginVersion; + // 初始化本地的core包数据 + var settingData = ATConfig.getPluginSettingData(); + if (settingData == null) { + settingData = new PluginSettingData(); + ATConfig.savePluginSettingData(settingData); + } + pluginData.country = settingData.curCountry; + pluginData.pluginSettingData = settingData; + pluginData.anyThink = initCoreNetworkWithLocalData(settingData); + return pluginData; + } + catch (Exception e) + { + // 错误处理代码 + ATLog.log("parse version data failed: " + e); + } + + return null; + } + + public static Network initCoreNetworkWithLocalData(PluginSettingData settingData) { + var network = new Network(); + var versions = new Versions(); + var countryData = settingData.getCountrySettingData(); + if (countryData != null) { + versions.Android = countryData.android_version; + versions.Ios = countryData.ios_version; + } + network.CurrentVersions = versions; + network.Country = settingData.curCountry; + return network; + } + + public static ServerNetworkInfo[] getServerNetworkInfo(bool isChina, ServerNetworkSdk serverNetworks, int os) { + if (serverNetworks == null) { + return null; + } + if (isChina) { + return serverNetworks.network_list.china; + } else { + return serverNetworks.network_list.nonchina; + } + } + + private static IEnumerable GetUniqueNetworkInfo(ServerNetworkInfo[] androidNetworks, ServerNetworkInfo[] iosNetworks) + { + // Android独有的 + var uniqueToAndroid = androidNetworks.Where(a => !iosNetworks.Any(i => i.displayName == a.displayName)); + + // iOS独有的 + var uniqueToIos = iosNetworks.Where(i => !androidNetworks.Any(a => a.displayName == i.displayName)); + + // 合并结果 + return uniqueToAndroid.Concat(uniqueToIos); + } + + //合并Android和iOS的network数据 + public static Network[] mergeAndroidIosNetworks(ServerNetworkInfo[] androidNetworks, ServerNetworkInfo[] iosNetworks) + { + int a_length = 0; + int i_length = 0; + if (androidNetworks != null) { + a_length = androidNetworks.Length; + } + if (iosNetworks != null) { + i_length = iosNetworks.Length; + } + ATLog.log("mergeAndroidIosNetworks() >>> a_length: " + a_length + " i_length: " + i_length); + + int max_length = Math.Max(a_length, i_length); + int min_length = Math.Min(a_length, i_length); + + var externalNetworks = androidNetworks; + var internalNetworks = iosNetworks; + if (a_length < i_length) { + externalNetworks = iosNetworks; + internalNetworks = androidNetworks; + } + + List networkList = new List(); + ATLog.log("mergeAndroidIosNetworks() >>> max_length: " + max_length + " min_length: " + min_length); + for (int i = 0; i < max_length; i++) { + var network = new Network(); + var iNetwork = externalNetworks[i]; + if (min_length == 0) { + //只有集成一个平台 + network = flatServerNetwork(iNetwork, network); + networkList.Add(network); + } else { + //合并相同的network + for (int j = 0; j < min_length; j++) { + var jNetwork = internalNetworks[j]; + if (Equals(iNetwork.displayName, jNetwork.displayName)) { + network = flatServerNetwork(iNetwork, network); + network = flatServerNetwork(jNetwork, network); + networkList.Add(network); + } + } + } + } + //过滤平台的唯一network + if (i_length > 0 && a_length > 0) { + var serverNetworkInfos = GetUniqueNetworkInfo(androidNetworks, iosNetworks); + foreach (var serverNetworkInfo in serverNetworkInfos) + { + var network = new Network(); + networkList.Add(flatServerNetwork(serverNetworkInfo, network)); + } + } + + return networkList.ToArray(); + } + + //后台下载数据转换成本地数据 + public static Network flatServerNetwork(ServerNetworkInfo serverInfo, Network network) + { + network.Name = serverInfo.name; + network.DisplayName = serverInfo.displayName; + network.Country = serverInfo.country; + network.PluginFileName = serverInfo.pluginFileName; + + var versions = network.LatestVersions; + if (versions == null) { + versions = new Versions(); + } + if (serverInfo.os == ATConfig.OS_ANDROID) { //Android + network.AndroidDownloadUrl = serverInfo.downloadUrl; + versions.Android = serverInfo.version; + } else { //iOS + network.iOSDownloadloadUrl = serverInfo.downloadUrl; + versions.Ios = serverInfo.version; + } + ATLog.log("flatServerNetwork() >>> name: " + network.Name + " androidVersion: " + versions.Android + " iosVersion: " + versions.Ios); + network.LatestVersions = versions; + return network; + } + + public static bool isChina(int country) + { + return country == ATConfig.CHINA_COUNTRY; + } + + + //只比较Android、iOS + public static VersionComparisonResult CompareVersions(string versionA, string versionB) + { + if (string.IsNullOrEmpty(versionA) || string.IsNullOrEmpty(versionB) || versionA.Equals(versionB)) + { + return VersionComparisonResult.Equal; + } + + try + { + var aVersionArrays = versionA.Split('.'); + var bVersionArrays = versionB.Split('.'); + + var arrayLength = Mathf.Min(aVersionArrays.Length, bVersionArrays.Length); + for (var i = 0; i < arrayLength; i++) + { + var aVersionStr = aVersionArrays[i]; + var bVersionStr = bVersionArrays[i]; + + var aVersionInt = int.Parse(aVersionStr); + var bVersionInt = int.Parse(bVersionStr); + + if (i == arrayLength - 1) //末尾最后一个 + { + if (aVersionStr.Length > bVersionStr.Length) + { + int gapLength = aVersionStr.Length - bVersionStr.Length; + bVersionInt = bVersionInt * (gapLength * 10); + } + else if (aVersionStr.Length < bVersionStr.Length) + { + int gapLength = bVersionStr.Length - aVersionStr.Length; + aVersionInt = aVersionInt * (gapLength * 10); + } + } + if (aVersionInt < bVersionInt) return VersionComparisonResult.Lesser; + if (aVersionInt > bVersionInt) return VersionComparisonResult.Greater; + } + } + catch (Exception e) + { + ATLog.logError("CompareVersions failed: " + e.Message); + } + + return VersionComparisonResult.Equal; + } + } + + //下发的插件数据:{"pluginVersion": "2.1.0", "platformName": "AnyThink", "ios_versions": ["6.2.88"], "android_versions": ["6.2.93"]} + [Serializable] + public class ServerPluginVersion + { + public string platformName; + // public string networkUrlVersion; + public string pluginVersion; + public string[] android_versions; + public string[] ios_versions; + } + + [Serializable] + public class ServerNetworks + { + public string plugin_version; + public ServerNetworkSdk[] ios_sdk; + public ServerNetworkSdk[] android_sdk; + } + + [Serializable] + public class ServerNetworkSdk + { + public string version; + public ServerNetworkListObj network_list; + } + + [Serializable] + public class ServerNetworkListObj + { + public ServerNetworkInfo[] china; + public ServerNetworkInfo[] nonchina; + } + + [Serializable] + public class ServerNetworkInfo + { + public string name; + public string displayName; + public string downloadUrl; + public string pluginFileName; + public string version; + public int os; + public int country; + // public ServerNetworkVersion versions; + } + [Serializable] + public class ServerNetworkVersion + { + public string android; + public string ios; + public string unity; + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATDataUtil.cs.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATDataUtil.cs.meta new file mode 100644 index 0000000..0cf6684 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATDataUtil.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a409a636a62d04b26ade7ade224489a0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATDownloadHandler.cs b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATDownloadHandler.cs new file mode 100644 index 0000000..a27cc79 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATDownloadHandler.cs @@ -0,0 +1,66 @@ +#if !UNITY_2017_2_OR_NEWER +using System; +using System.IO; +using UnityEngine.Networking; + +namespace AnyThink.Scripts.IntegrationManager.Editor +{ + public class ATDownloadHandler : DownloadHandlerScript + { + // Required by DownloadHandler base class. Called when you address the 'bytes' property. + protected override byte[] GetData() + { + return null; + } + + private FileStream fileStream; + + public ATDownloadHandler(string path) : base(new byte[2048]) + { + var downloadDirectory = Path.GetDirectoryName(path); + if (!Directory.Exists(downloadDirectory)) + { + Directory.CreateDirectory(downloadDirectory); + } + + try + { + //Open the current file to write to + fileStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite); + } + catch (Exception exception) + { + // MaxSdkLogger.UserError(string.Format("Failed to create file at {0}\n{1}", path, exception.Message)); + ATLog.logError(string.Format("Failed to create file at {0}\n{1}", path, exception.Message)); + } + } + + protected override bool ReceiveData(byte[] byteFromServer, int dataLength) + { + if (byteFromServer == null || byteFromServer.Length < 1 || fileStream == null) + { + return false; + } + + try + { + //Write the current data to the file + fileStream.Write(byteFromServer, 0, dataLength); + } + catch (Exception exception) + { + fileStream.Close(); + fileStream = null; + ATLog.logError(string.Format("Failed to download file{0}", exception.Message)); + } + + return true; + } + + protected override void CompleteContent() + { + fileStream.Close(); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATDownloadHandler.cs.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATDownloadHandler.cs.meta new file mode 100644 index 0000000..65410bf --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATDownloadHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5bafb0360f71b4552859c091a9309513 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATEditorCoroutine.cs b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATEditorCoroutine.cs new file mode 100644 index 0000000..e922e3c --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATEditorCoroutine.cs @@ -0,0 +1,74 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEditor; + +namespace AnyThink.Scripts.IntegrationManager.Editor +{ + public class ATEditorCoroutine + { + /// + /// Keeps track of the coroutine currently running. + /// + private IEnumerator enumerator; + + /// + /// Keeps track of coroutines that have yielded to the current enumerator. + /// + private readonly List history = new List(); + + private ATEditorCoroutine(IEnumerator enumerator) { + this.enumerator = enumerator; + } + + + public static ATEditorCoroutine startCoroutine(IEnumerator enumerator) { + var coroutine = new ATEditorCoroutine(enumerator); + coroutine.Start(); + return coroutine; + } + + private void Start() + { + EditorApplication.update += OnEditorUpdate; + } + + /// + /// Stops the coroutine. + /// + public void Stop() + { + if (EditorApplication.update == null) return; + + EditorApplication.update -= OnEditorUpdate; + } + + private void OnEditorUpdate() + { + if (enumerator.MoveNext()) + { + // If there is a coroutine to yield for inside the coroutine, add the initial one to history and continue the second one + if (enumerator.Current is IEnumerator) + { + history.Add(enumerator); + enumerator = (IEnumerator) enumerator.Current; + } + } + else + { + // Current coroutine has ended, check if we have more coroutines in history to be run. + if (history.Count == 0) + { + // No more coroutines to run, stop updating. + Stop(); + } + // Step out and finish the code in the coroutine that yielded to it + else + { + var index = history.Count - 1; + enumerator = history[index]; + history.RemoveAt(index); + } + } + } + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATEditorCoroutine.cs.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATEditorCoroutine.cs.meta new file mode 100644 index 0000000..a98d179 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATEditorCoroutine.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3fc3656e471f54d6eafd9a258b89d23c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntegrationManager.cs b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntegrationManager.cs new file mode 100644 index 0000000..10da9df --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntegrationManager.cs @@ -0,0 +1,447 @@ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Xml.Linq; +using UnityEditor; +using UnityEngine; +using UnityEngine.Networking; +using UnityEditor.PackageManager.Requests; +using UnityEditor.PackageManager; +using System.Threading.Tasks; +using System.Threading; + +namespace AnyThink.Scripts.IntegrationManager.Editor +{ + public class ATIntegrationManager + { + public static ATIntegrationManager Instance = new ATIntegrationManager(); + + // private UnityWebRequest downloadPluginRequest; + + private const string AnyThinkAds = "AnyThinkAds"; + //AnyThink的unity插件 + public static string AnyThinkNetworkName = "Core"; + + private PluginData mPluginData; + + private ATIntegrationManager() + { + + } + + public void CancelDownload() + { + // if (downloadPluginRequest == null) return; + + // downloadPluginRequest.Abort(); + } + + public IEnumerator loadPluginData(Action callback) + { + var thinkupVersionRequest = UnityWebRequest.Get(ATNetInfo.getPluginConfigUrl(ATConfig.PLUGIN_VERSION)); + var webRequest = thinkupVersionRequest.SendWebRequest(); + while (!webRequest.isDone) + { + yield return new WaitForSeconds(0.1f); + } + +#if UNITY_2020_1_OR_NEWER + if (thinkupVersionRequest.result != UnityWebRequest.Result.Success) +#elif UNITY_2017_2_OR_NEWER + if (thinkupVersionRequest.isNetworkError || thinkupVersionRequest.isHttpError) +#else + if (thinkupVersionRequest.isError) +#endif + { + Debug.Log("loadPluginData failed."); + callback(null); + } + else + { + //解析Anythink的版本数据 + string thinkupVersionJson = thinkupVersionRequest.downloadHandler.text; + PluginData pluginData = ATDataUtil.parsePluginDataJson(thinkupVersionJson); + Debug.Log("loadPluginData succeed. country: " + pluginData.country + " androidVersions: " + + pluginData.androidVersions + " iosVersions: " + pluginData.iosVersions); + mPluginData = pluginData; + callback(pluginData); + } + } + + public IEnumerator loadNetworksData(PluginData pluginData, Action callback) + { + + Network network = pluginData.anyThink; + if (pluginData == null) + { + callback(null); + } + else if (pluginData.requestParams == null) { + ATLog.log("loadNetworksData() >>> pluginData.requestParams is null"); + callback(pluginData); + } + else + { + var networksRequest = UnityWebRequest.Get(ATNetInfo.getNetworkListUrl(ATConfig.PLUGIN_VERSION)); + var webRequest = networksRequest.SendWebRequest(); + while (!webRequest.isDone) + { + yield return new WaitForSeconds(0.1f); + } + +#if UNITY_2020_1_OR_NEWER + if (networksRequest.result != UnityWebRequest.Result.Success) +#elif UNITY_2017_2_OR_NEWER + if (networksRequest.isNetworkError || networksRequest.isHttpError) +#else + if (networksRequest.isError) +#endif + { + Debug.Log("loadNetworksData failed."); + callback(pluginData); + } + else + { + //解析network列表的版本数据 + string netowrksJson = networksRequest.downloadHandler.text; + ATLog.log("loadNetworksData() >>> netowrksJson: " + netowrksJson); + pluginData.mediatedNetworks = ATDataUtil.parseNetworksJson(pluginData, netowrksJson); + ATLog.log("loadNetworksData() >>> mediatedNetworks: " + pluginData.mediatedNetworks); + mPluginData = pluginData; + callback(pluginData); + } + } + } + + /// + /// Downloads the plugin file for a given network. + /// + /// Network for which to download the current version. + /// Whether or not to show the import window when downloading. Defaults to true. + /// + public void downloadPlugin(Network network, int os =1, bool showImport = false) + { + ATEditorCoroutine.startCoroutine(downloadPluginWithEnumerator(network, os, showImport)); + } + + public IEnumerator downloadPluginWithEnumerator(Network network, int os, bool showImport) + { + ATLog.log("downloadPluginWithEnumerator() >>> networkName: " + network.Name + " os: " + os); + // if (downloadPluginRequest != null) + // { + // downloadPluginRequest.Dispose(); + // } + var path = Path.Combine(Application.temporaryCachePath, network.PluginFileName); + ATLog.log("downloadPluginWithEnumerator() >>> path: " + path); +#if UNITY_2017_2_OR_NEWER + var downloadHandler = new DownloadHandlerFile(path); +#else + var downloadHandler = new ATDownloadHandler(path); +#endif + var downloadUrl = network.AndroidDownloadUrl; + if (os == ATConfig.OS_IOS) + { + downloadUrl = network.iOSDownloadloadUrl; + } + UnityWebRequest downloadPluginRequest = new UnityWebRequest(downloadUrl) + { method = UnityWebRequest.kHttpVerbGET, + downloadHandler = downloadHandler + }; + +#if UNITY_2017_2_OR_NEWER + var operation = downloadPluginRequest.SendWebRequest(); +#else + var operation = downloadPluginRequest.Send(); +#endif + while (!operation.isDone) + { + yield return new WaitForSeconds(0.1f); // Just wait till downloadPluginRequest is completed. Our coroutine is pretty rudimentary. + if (operation.progress != 1 && operation.isDone) + { + // CallDownloadPluginProgressCallback(network.DisplayName, operation.progress, operation.isDone, os); + UpdateCurrentVersions(network, os); + } + } + +#if UNITY_2020_1_OR_NEWER + if (downloadPluginRequest.result != UnityWebRequest.Result.Success) +#elif UNITY_2017_2_OR_NEWER + if (downloadPluginRequest.isNetworkError || downloadPluginRequest.isHttpError) +#else + if (downloadPluginRequest.isError) +#endif + { + ATLog.logError(downloadPluginRequest.error); + } + else + { + AssetDatabase.ImportPackage(path, showImport); + UpdateCurrentVersions(network, os); + AssetDatabase.Refresh(); + } + downloadPluginRequest.Dispose(); + downloadPluginRequest = null; + } + + //默认下载core包,在下载完network的数据时。 + public void downloadCorePlugin(PluginData pluginData) + { + mPluginData = pluginData; + var requestParams = pluginData.requestParams; + var pluginSettingData = pluginData.pluginSettingData; + + bool isIosInstalled = ATConfig.isCoreNetworkInstalled(pluginSettingData, ATConfig.OS_IOS); + bool isAndroidInstalled = ATConfig.isCoreNetworkInstalled(pluginSettingData, ATConfig.OS_ANDROID); + ATLog.log("downloadCorePlugin() >>> isIosInstalled: " + isIosInstalled + " isAndroidInstalled: " + isAndroidInstalled); + + Network network = pluginData.anyThink; + int os = requestParams.os; + if (os == ATConfig.OS_ANDROID) { + if (!isAndroidInstalled) { + downloadPlugin(network, os); + } else { + //判断是否需要切换SDK + var latestVersions = network.LatestVersions; + var curVersion = network.CurrentVersions; + if (latestVersions.Android != curVersion.Android) { + //先删除掉core包 + ATConfig.removeSdk(pluginData.country, os); + removeNetworkVersions(pluginData, os); + //赋值当前版本为空 + curVersion.Android = ""; + //重新下载core包 + downloadPlugin(network, os); + //重新下载已安装的network + redownloadNetworksPlugin(pluginData, os); + } + } + } else if (os == ATConfig.OS_IOS){ + if (!isIosInstalled) { + downloadPlugin(network, os); + } else { + //判断是否需要切换SDK + var latestVersions = network.LatestVersions; + var curVersion = network.CurrentVersions; + if (latestVersions.Ios != curVersion.Ios) { + //先删除掉core包 + ATConfig.removeSdk(pluginData.country, os); + removeNetworkVersions(pluginData, os); + //赋值当前版本为空 + curVersion.Ios = ""; + //重新下载core包 + downloadPlugin(network, os); + //重新下载已安装的network + redownloadNetworksPlugin(pluginData, os); + } + } + } + } + + //当切换SDK版本时,需要重新下载已安装的network + private void redownloadNetworksPlugin(PluginData pluginData, int os) { + var mediatedNetworks = pluginData.mediatedNetworks; + var needInstallNetworkList = new List(); + foreach(Network network in mediatedNetworks) { + var currentVersion = network.CurrentVersions; + if (currentVersion != null) { + if (os == ATConfig.OS_ANDROID) { + if (!string.IsNullOrEmpty(currentVersion.Android)) { + needInstallNetworkList.Add(network); + } + } else { + if (!string.IsNullOrEmpty(currentVersion.Ios)) { + needInstallNetworkList.Add(network); + } + } + } + } + if (needInstallNetworkList.Count() == 0) { + return; + } + Thread.Sleep(500); + ATEditorCoroutine.startCoroutine(UpgradeAllNetworks(needInstallNetworkList, os)); + } + + private IEnumerator UpgradeAllNetworks(List networks, int os) { + EditorApplication.LockReloadAssemblies(); + foreach (var network in networks) + { + + yield return downloadPluginWithEnumerator(network, os, false); + } + EditorApplication.UnlockReloadAssemblies(); + } + + public void networkInstallOrUpdate(PluginData pluginData, Network network, int os) + { + downloadPlugin(network, os); + } + + //更新network已安装的版本 + private void UpdateCurrentVersions(Network network, int os) + { + var latestVersions = network.LatestVersions; + var versions = network.CurrentVersions; + if (versions == null) { + versions = new Versions(); + } + if (os == ATConfig.OS_ANDROID) { + versions.Android = latestVersions.Android; + } else { + versions.Ios = latestVersions.Ios; + } + network.CurrentVersions = versions; + + // await Task.Delay(1000); + // Thread.Sleep(1000); + //下面的逻辑会延迟一秒后执行,确保unitypackage先解压到本地 + ATConfig.saveInstalledNetworkVersion(network, os); + ATLog.log("UpdateCurrentVersions() >>> AndroidVersion: " + versions.Android); + //保存Core Networkde + if (ATConfig.isCoreNetwork(network.Name)) { + var countrySettingData = mPluginData.pluginSettingData.getCountrySettingData(); + if (os == ATConfig.OS_ANDROID) { + countrySettingData.android_version = latestVersions.Android; + } else { + countrySettingData.ios_version = latestVersions.Ios; + } + + ATConfig.savePluginSettingData(mPluginData.pluginSettingData); + } + // ATLog.log("UpdateCurrentVersions() >>> Name: " + network.Name + " latest Unity Version: " + network.LatestVersions.Unity); + } + + //点击了界面的network删除按钮 + public void uninstallNetwork(Network network, int os) + { + var result = ATConfig.removeInstalledNetwork(network, os); + if (result) { + if (os == ATConfig.OS_ANDROID){ + network.CurrentVersions.Android = ""; + } else { + network.CurrentVersions.Ios = ""; + } + } + } + + //切换国家 + public void switchCountry(PluginData pluginData, int country) { + pluginData.country = country; + + var pluginSettingData = pluginData.pluginSettingData; + pluginSettingData.curCountry = country; + + ATConfig.savePluginSettingData(pluginSettingData); + } + + //获取AndroidX开关状态 + public int getAndroidXSetting(PluginData pluginData) { + if (pluginData == null) { + return 0; + } + var pluginSettingData = pluginData.pluginSettingData; + if (pluginSettingData == null) { + return 0; + } + CountrySettingData countrySettingData = pluginSettingData.getCountrySettingData(); + return countrySettingData.androidXSetting; + } + + //设置并保存AndroidX开关状态 + public void saveAndroidXSetting(PluginData pluginData, int androidXSetting) { + ATLog.log("saveAndroidXSetting() >>> androidXSetting: " + androidXSetting); + var pluginSettingData = pluginData.pluginSettingData; + CountrySettingData countrySettingData = pluginSettingData.getCountrySettingData(); + countrySettingData.androidXSetting = androidXSetting; + + ATConfig.savePluginSettingData(pluginSettingData); + } + + //根据系统判断Admob是否有安装 + public bool isAdmobInstalled(int os) { + return ATConfig.isNetworkInstalledByName("Admob", os); + } + + public string getAdmobAppIdByOs(PluginData pluginData, int os) { + if (pluginData == null) { + return ""; + } + //android_admob_app_id + var countrySettingData = pluginData.pluginSettingData.getCountrySettingData(); + return countrySettingData.getAdmobAppId(os); + } + + //设置保存Admob app id + public void setAdmobAppidByOs(PluginData pluginData, int os, string appId) { + if (pluginData == null || pluginData.pluginSettingData == null) { + return; + } + var countrySettingData = pluginData.pluginSettingData.getCountrySettingData(); + countrySettingData.setAdmobAppId(appId, os); + + ATConfig.savePluginSettingData(pluginData.pluginSettingData); + } + + //删除某个版本的SDK + public void deleteSdk(PluginData pluginData, string sdkVersion, int os) { + ATLog.log("deleteSdk() >>> sdkVersion: " + sdkVersion + " os: " + os); + //删除本地文件 + ATConfig.removeSdk(pluginData.country, os); + //修改UI显示 + removeNetworkVersions(pluginData, os, true); + var curVersions = pluginData.anyThink.CurrentVersions; + //修改sdk本地配置文件 + var pluginSettingData = pluginData.pluginSettingData; + CountrySettingData countrySettingData = pluginSettingData.getCountrySettingData(); + + if (os == ATConfig.OS_ANDROID) { + curVersions.Android = ""; + countrySettingData.android_version = ""; + } else { + curVersions.Ios = ""; + countrySettingData.ios_version = ""; + } + + ATConfig.savePluginSettingData(pluginSettingData); + } + + private void removeNetworkVersions(PluginData pluginData, int os, bool isDeleteSdk = false) { + if (isDeleteSdk) { + var mediatedNetworks = pluginData.mediatedNetworks; + if (mediatedNetworks != null && mediatedNetworks.Length > 0) { + foreach(Network network in mediatedNetworks) { + var currentVersion = network.CurrentVersions; + if (currentVersion != null) { + if (os == ATConfig.OS_ANDROID) { + currentVersion.Android = ""; + } else { + currentVersion.Ios = ""; + } + } + var latestVersions = network.LatestVersions; + if (latestVersions != null) { + if (os == ATConfig.OS_ANDROID) { + latestVersions.Android = ""; + } else { + latestVersions.Ios = ""; + } + } + } + } + NetworkRequestParams requestParams = pluginData.requestParams; + if (requestParams == null) { + return; + } + if (os == ATConfig.OS_ANDROID) { //Android + requestParams.androidVersion = ""; + } else { + requestParams.iosVersion = ""; + } + } + } + } +} diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntegrationManager.cs.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntegrationManager.cs.meta new file mode 100644 index 0000000..232bbac --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntegrationManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bf2178e4a7ba941cba8ae0367e521ea9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntegrationManagerWindow.cs b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntegrationManagerWindow.cs new file mode 100644 index 0000000..4845920 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntegrationManagerWindow.cs @@ -0,0 +1,860 @@ +using System; +using System.Collections; +using System.IO; +using System.Linq; +using UnityEditor; +using UnityEngine; +using UnityEngine.UI; +using System.Collections.Generic; +using System.Text; + +namespace AnyThink.Scripts.IntegrationManager.Editor +{ + public class ATIntegrationManagerWindow : EditorWindow + { + + private const string windowTitle = "ThinkupTpn Integration Manager"; + private const string uninstallIconExportPath = "ThinkupTpnPlugin/Resources/Images/uninstall_icon.png"; + private const string alertIconExportPath = "ThinkupTpnPlugin/Resources/Images/alert_icon.png"; + private const string warningIconExportPath = "ThinkupTpnPlugin/Resources/Images/warning_icon.png"; + + private static readonly Color darkModeTextColor = new Color(0.29f, 0.6f, 0.8f); + private GUIStyle titleLabelStyle; + private GUIStyle headerLabelStyle; + private GUIStyle environmentValueStyle; + private GUIStyle wrapTextLabelStyle; + private GUIStyle linkLabelStyle; + private GUIStyle iconStyle; + private GUIStyle tipTextStyle; + private Texture2D uninstallIcon; + private Texture2D alertIcon; + private Texture2D warningIcon; + private Vector2 scrollPosition; + private static readonly Vector2 windowMinSize = new Vector2(850, 750); + private const float actionFieldWidth = 80f; + private const float upgradeAllButtonWidth = 80f; + private const float networkFieldMinWidth = 200f; + private const float versionFieldMinWidth = 200f; + private const float privacySettingLabelWidth = 200f; + private const float networkFieldWidthPercentage = 0.22f; + private const float versionFieldWidthPercentage = 0.36f; // There are two version fields. Each take 40% of the width, network field takes the remaining 20%. + private static float previousWindowWidth = windowMinSize.x; + private static GUILayoutOption networkWidthOption = GUILayout.Width(networkFieldMinWidth); + private static GUILayoutOption versionWidthOption = GUILayout.Width(versionFieldMinWidth); + + private static GUILayoutOption sdkKeyTextFieldWidthOption = GUILayout.Width(520); + + private static GUILayoutOption privacySettingFieldWidthOption = GUILayout.Width(400); + private static readonly GUILayoutOption fieldWidth = GUILayout.Width(actionFieldWidth); + private static readonly GUILayoutOption upgradeAllButtonFieldWidth = GUILayout.Width(upgradeAllButtonWidth); + + private ATEditorCoroutine loadDataCoroutine; + private PluginData pluginData; + private bool pluginDataLoadFailed; + private bool networkButtonsEnabled = true; + private bool shouldShowGoogleWarning; + private int curSelectCountryInt; + // private int dropdownIndex = 0; + private int androidVersionPopupIndex; + private int iosVersionPopupIndex; + + + public static void ShowManager() + { + var manager = GetWindow(utility: true, title: windowTitle, focus: true); + manager.minSize = windowMinSize; + // manager.maxSize = windowMinSize; + } + //定义UI的Style + private void Awake() + { + titleLabelStyle = new GUIStyle(EditorStyles.label) + { + fontSize = 14, + fontStyle = FontStyle.Bold, + fixedHeight = 20 + }; + + headerLabelStyle = new GUIStyle(EditorStyles.label) + { + fontSize = 12, + fontStyle = FontStyle.Bold, + fixedHeight = 18 + }; + + environmentValueStyle = new GUIStyle(EditorStyles.label) + { + alignment = TextAnchor.MiddleRight + }; + + linkLabelStyle = new GUIStyle(EditorStyles.label) + { + wordWrap = true, + normal = { textColor = EditorGUIUtility.isProSkin ? darkModeTextColor : Color.blue } + }; + + wrapTextLabelStyle = new GUIStyle(EditorStyles.label) + { + wordWrap = true + }; + + iconStyle = new GUIStyle(EditorStyles.miniButton) + { + fixedWidth = 18, + fixedHeight = 18, + padding = new RectOffset(1, 1, 1, 1) + }; + + tipTextStyle = new GUIStyle(EditorStyles.label) + { + normal = { textColor = Color.yellow } + }; + + // Load uninstall icon texture. + var uninstallIconData = File.ReadAllBytes(ATSdkUtil.GetAssetPathForExportPath(uninstallIconExportPath)); + uninstallIcon = new Texture2D(100, 100, TextureFormat.RGBA32, false); // 1. Initial size doesn't matter here, will be automatically resized once the image asset is loaded. 2. Set mipChain to false, else the texture has a weird blurry effect. + uninstallIcon.LoadImage(uninstallIconData); + + // Load alert icon texture. + var alertIconData = File.ReadAllBytes(ATSdkUtil.GetAssetPathForExportPath(alertIconExportPath)); + alertIcon = new Texture2D(100, 100, TextureFormat.RGBA32, false); + alertIcon.LoadImage(alertIconData); + + // Load warning icon texture. + var warningIconData = File.ReadAllBytes(ATSdkUtil.GetAssetPathForExportPath(warningIconExportPath)); + warningIcon = new Texture2D(100, 100, TextureFormat.RGBA32, false); + warningIcon.LoadImage(warningIconData); + + loadPluginData(); + //热更新 + ATIntegrationHotFix.Instance.loadHotFixData(); + } + + //这个方法在插件启动时会调用,然后脚本重新加载时也会重新调用,所以加载数据放在Awake中 + private void OnEnable() + { + + } + + private void OnDisable() + { + if (loadDataCoroutine != null) + { + loadDataCoroutine.Stop(); + loadDataCoroutine = null; + } + + ATIntegrationManager.Instance.CancelDownload(); + EditorUtility.ClearProgressBar(); + + // Saves the AppLovinSettings object if it has been changed. + AssetDatabase.SaveAssets(); + } + + private void OnDestroy() { + ATLog.log("OnDestroy() >>> called"); + } + + + private void OnGUI() + { + // OnGUI is called on each frame draw, so we don't want to do any unnecessary calculation if we can avoid it. So only calculate it when the width actually changed. + if (Math.Abs(previousWindowWidth - position.width) > 1) + { + previousWindowWidth = position.width; + CalculateFieldWidth(); + } + using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPosition, false, false)) + { + scrollPosition = scrollView.scrollPosition; + GUILayout.Space(5); + // EditorGUILayout.LabelField("Region (Only for Android, iOS is not affected by region)", titleLabelStyle); + EditorGUILayout.LabelField("Region", titleLabelStyle); + DrawCountryUI(); + DrawCountrySwitchTip(); + DrawAndroidXUI(); + DrawAdombAppId(); + EditorGUILayout.LabelField("ThinkupTpn Plugin Details", titleLabelStyle); + //显示插件版本号 + DrawPluginDetails(); + //绘制SDK版本下架提示 + DrawSdkVersionOffTip(); + //绘制Networks + DrawMediatedNetworks(); + } + if (GUI.changed) + { + AssetDatabase.SaveAssets(); + } + } + + /// + /// Callback method that will be called with progress updates when the plugin is being downloaded. + /// + public static void OnDownloadPluginProgress(string pluginName, float progress, bool done) + { + ATLog.logFormat("OnDownloadPluginProgress() >>> pluginName: {0}, progress: {1}, done: {2}", new object[] { pluginName, progress, done }); + // Download is complete. Clear progress bar. + if (done || progress == 1) + { + EditorUtility.ClearProgressBar(); + AssetDatabase.Refresh(); + } + // Download is in progress, update progress bar. + else + { + if (EditorUtility.DisplayCancelableProgressBar(windowTitle, string.Format("Downloading {0} plugin...", pluginName), progress)) + { + ATLog.log("OnDownloadPluginProgress() >>> click cancel download"); + ATIntegrationManager.Instance.CancelDownload(); + EditorUtility.ClearProgressBar(); + AssetDatabase.Refresh(); + } + } + } + + public void DeleteSdkVersion(PluginData pluginData, int index, int os) { + var sdkVersion = pluginData.androidVersions[index]; + if (os == ATConfig.OS_IOS) { + sdkVersion = pluginData.iosVersions[index]; + } + ATIntegrationManager.Instance.deleteSdk(pluginData, sdkVersion, os); + } + + public void ExChangeSDKVersion(PluginData pluginData, int index, int os) { + NetworkRequestParams requestParams = pluginData.requestParams; + if (requestParams == null) { + requestParams = new NetworkRequestParams(); + } + requestParams.os = os; + if (os == ATConfig.OS_ANDROID) { //Android + requestParams.androidVersion = pluginData.androidVersions[index]; + } else { + requestParams.iosVersion = pluginData.iosVersions[index]; + } + pluginData.requestParams = requestParams; + // ATLog.log("ExChangeSDKVersion() >>> versions.Android: " + versions.Android + " versions.Ios: " + versions.Ios); + loadNetworksData(pluginData); + } + + //获取插件和SDK的版本数据 + private void loadPluginData() + { + if (loadDataCoroutine != null) + { + loadDataCoroutine.Stop(); + } + loadDataCoroutine = ATEditorCoroutine.startCoroutine(ATIntegrationManager.Instance.loadPluginData(data => + { + if (data == null) + { + pluginDataLoadFailed = true; + } + else + { + ATLog.log("loadNetworksData() >>> pluginData: " + data); + pluginData = data; + pluginDataLoadFailed = false; + + var versions = pluginData.anyThink.CurrentVersions; + if (versions != null) { + var requestParams = new NetworkRequestParams(); + requestParams.androidVersion = versions.Android; + requestParams.iosVersion = versions.Ios; + pluginData.requestParams = requestParams; + } + loadNetworksData(pluginData); + } + + CalculateFieldWidth(); + Repaint(); + })); + } + //获取networks + private void loadNetworksData(PluginData pluginData) + { + ATEditorCoroutine.startCoroutine(ATIntegrationManager.Instance.loadNetworksData(pluginData, data => + { + pluginData = data; + Network network = pluginData.anyThink; + if (!string.IsNullOrEmpty(network.AndroidDownloadUrl) || !string.IsNullOrEmpty(network.iOSDownloadloadUrl)) { + ATIntegrationManager.Instance.downloadCorePlugin(data); + } + Repaint(); + })); + } + //切换国家,重新加载数据 + private void switchCountry(int country) + { + ATIntegrationManager.Instance.switchCountry(pluginData, country); + //重新开始走network + loadPluginData(); + } + + private void CalculateFieldWidth() + { + var currentWidth = position.width; + var availableWidth = currentWidth - actionFieldWidth - 80; // NOTE: Magic number alert. This is the sum of all the spacing the fields and other UI elements. + var networkLabelWidth = Math.Max(networkFieldMinWidth, availableWidth * networkFieldWidthPercentage); + networkWidthOption = GUILayout.Width(networkLabelWidth); + + var versionLabelWidth = Math.Max(versionFieldMinWidth, availableWidth * versionFieldWidthPercentage); + versionWidthOption = GUILayout.Width(versionLabelWidth); + + const int textFieldOtherUiElementsWidth = 45; // NOTE: Magic number alert. This is the sum of all the spacing the fields and other UI elements. + var availableTextFieldWidth = currentWidth - networkLabelWidth - textFieldOtherUiElementsWidth; + sdkKeyTextFieldWidthOption = GUILayout.Width(availableTextFieldWidth); + + var availableUserDescriptionTextFieldWidth = currentWidth - privacySettingLabelWidth - textFieldOtherUiElementsWidth; + privacySettingFieldWidthOption = GUILayout.Width(availableUserDescriptionTextFieldWidth); + } + + private void DrawCountryUI() + { + // GUILayout.BeginHorizontal(); + GUILayout.Space(4); + using (new EditorGUILayout.HorizontalScope("box")) + { + GUILayout.Space(5); + + int countryInt = ATConfig.getDefCountry(); //默认是中国 + if (pluginData != null) + { + countryInt = pluginData.country; + } + + string[] options = ATConfig.getCountryArray(); + // 创建Dropdown组件 + int curDropdownIndex = ATDataUtil.isChina(countryInt) ? 0 : 1; + if (options.Length == 1) { + curDropdownIndex = 0; + } + int dropdownIndex = EditorGUILayout.Popup("Select Region:", curDropdownIndex, options); + + if (options.Length > 1) { + curSelectCountryInt = dropdownIndex == 0 ? ATConfig.CHINA_COUNTRY : ATConfig.NONCHINA_COUNTRY; + //变化才设置 + if (pluginData != null && curSelectCountryInt != countryInt) + { + ATLog.log("DrawCountryUI() >>> curSelectCountryInt: " + curSelectCountryInt + " countryInt: " + countryInt); + //Unity需要更换Network + switchCountry(curSelectCountryInt); + } + } + GUILayout.Space(5); + } + GUILayout.Space(4); + // GUILayout.EndHorizontal(); + } + + private void DrawCountrySwitchTip() + { + var integratedTip = ATConfig.getRegionIntegrateTip(); + if (string.IsNullOrEmpty(integratedTip)) { + return; + } + GUILayout.Space(4); + // textStyle.fontStyle = FontStyle.Bold; + EditorGUILayout.LabelField(integratedTip, tipTextStyle); + GUILayout.Space(4); + } + + private void DrawAndroidXUI() + { + bool isChina = ATConfig.isSelectedChina(); + // if (!ATConfig.isSelectedChina()) { + // return; + // } + EditorGUILayout.LabelField("AndroidX (Only for Android)", titleLabelStyle); + GUILayout.Space(4); + using (new EditorGUILayout.HorizontalScope("box")) + { + GUILayout.Space(5); + + int androidXSetting = ATIntegrationManager.Instance.getAndroidXSetting(pluginData); + string[] options = new string[] { "Default", "Enable", "Disable" }; + if (!isChina) { + options = new string[] { "Default", "Enable" }; + } + // 创建Dropdown组件 + int lastDropdownIndex = androidXSetting; + int curDropdownIndex = EditorGUILayout.Popup("Enable AndroidX:", lastDropdownIndex, options); + + //变化才设置 + if (curDropdownIndex != lastDropdownIndex) + { + ATLog.log("DrawAndroidXUI() >>> curDropdownIndex: " + curDropdownIndex + " lastDropdownIndex: " + lastDropdownIndex); + ATIntegrationManager.Instance.saveAndroidXSetting(pluginData, curDropdownIndex); + } + GUILayout.Space(5); + } + GUILayout.Space(4); + } + + private void DrawPluginDetails() + { + // GUILayout.BeginHorizontal(); + GUILayout.Space(10); + using (new EditorGUILayout.VerticalScope("box")) + { + // Draw plugin version details + DrawHeaders("Platform", true); + DrawPluginDetailRow("Unity Plugin", ATConfig.PLUGIN_VERSION, "", ""); + if (pluginData == null) + { + DrawEmptyPluginData("loading sdk data ..."); + return; + } + + var thinkup = pluginData.anyThink; + var android_version = ""; + var ios_version = ""; + if (thinkup != null) { + android_version = thinkup.CurrentVersions.Android; + ios_version = thinkup.CurrentVersions.Ios; + } + //绘制Android + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.Space(5); + EditorGUILayout.LabelField(new GUIContent("Android"), networkWidthOption); + EditorGUILayout.LabelField(new GUIContent(android_version), versionWidthOption); + GUILayout.Space(3); + + string[] androidVersions = pluginData.androidVersions; + if (androidVersions != null && androidVersions.Length > 0) { + List androidVersionsInt = new List(); + int androidLength = androidVersions.Length; + for (int i = 0; i < androidLength; i = i + 1) + { + androidVersionsInt.Add(i); + } + + // 创建Dropdown组件 + androidVersionPopupIndex = EditorGUILayout.IntPopup(androidVersionPopupIndex, androidVersions, androidVersionsInt.ToArray(), versionWidthOption); + GUILayout.FlexibleSpace(); + string selectedAndroidVersion = androidVersions[androidVersionPopupIndex]; + string action = "Exchange"; + if (!string.IsNullOrEmpty(android_version) && Equals(android_version, selectedAndroidVersion)) { + action = "Delete"; + } + GUI.enabled = (!Equals(android_version, selectedAndroidVersion)) || action == "Delete"; + if (GUILayout.Button(new GUIContent(action), fieldWidth)) + { + //切换AndroidSDK版本 + if (action == "Delete") { + DeleteSdkVersion(pluginData, androidVersionPopupIndex, ATConfig.OS_ANDROID); + } else { + ExChangeSDKVersion(pluginData, androidVersionPopupIndex, ATConfig.OS_ANDROID); + } + } + GUI.enabled = true; + GUILayout.Space(5); + } else { + EditorGUILayout.LabelField(new GUIContent("loading..."), versionWidthOption); + } + + GUILayout.Space(3); + } + //绘制iOS + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.Space(5); + EditorGUILayout.LabelField(new GUIContent("iOS"), networkWidthOption); + EditorGUILayout.LabelField(new GUIContent(ios_version), versionWidthOption); + GUILayout.Space(3); + + string[] iosVersions = pluginData.iosVersions; + if (iosVersions != null && iosVersions.Length > 0) { + List iosVersionsInt = new List(); + int androidLength = iosVersions.Length; + for (int i = 0; i < androidLength; i = i + 1) + { + iosVersionsInt.Add(i); + } + + // 创建Dropdown组件 + iosVersionPopupIndex = EditorGUILayout.IntPopup(iosVersionPopupIndex, iosVersions, iosVersionsInt.ToArray(), versionWidthOption); + GUILayout.FlexibleSpace(); + string selectedIosVersion = iosVersions[iosVersionPopupIndex]; + + string action = "Exchange"; + if (!string.IsNullOrEmpty(ios_version) && Equals(ios_version, selectedIosVersion)) { + action = "Delete"; + } + GUI.enabled = !Equals(ios_version, selectedIosVersion) || action == "Delete"; + if (GUILayout.Button(new GUIContent(action), fieldWidth)) + { + if (action == "Delete") { + DeleteSdkVersion(pluginData, iosVersionPopupIndex, ATConfig.OS_IOS); + } else { + ExChangeSDKVersion(pluginData, iosVersionPopupIndex, ATConfig.OS_IOS); + } + } + GUI.enabled = true; + GUILayout.Space(5); + } else { + EditorGUILayout.LabelField(new GUIContent("loading..."), versionWidthOption); + } + + GUILayout.Space(3); + } + + GUILayout.Space(4); + +#if !UNITY_2018_2_OR_NEWER + EditorGUILayout.HelpBox("AnyThink Unity plugin will soon require Unity 2018.2 or newer to function. Please upgrade to a newer Unity version.", MessageType.Warning); +#endif + } + + GUILayout.Space(5); + // GUILayout.EndHorizontal(); + } + + private void DrawSdkVersionOffTip() + { + if (pluginData == null) { + return; + } + var thinkup = pluginData.anyThink; + if (thinkup == null) { + return; + } + var android_version = ""; + var ios_version = ""; + if (thinkup != null) { + android_version = thinkup.CurrentVersions.Android; + ios_version = thinkup.CurrentVersions.Ios; + //判断android版本是否版本列表中 + string[] androidVersions = pluginData.androidVersions; + string[] iosVersions = pluginData.iosVersions; + + //The currently installed Android version and io version have been offline + StringBuilder sb = new StringBuilder(); + sb.Append("Tips: The currently installed "); + + var android_version_off = false; + if (!string.IsNullOrEmpty(android_version) && androidVersions != null && androidVersions.Length > 0) { + if (!IsCharInStringArray(android_version, androidVersions)) { + sb.Append("Android version("); + sb.Append(android_version); + sb.Append(") "); + android_version_off = true; + } + } + var ios_version_off = false; + if (!string.IsNullOrEmpty(ios_version) && iosVersions != null && iosVersions.Length > 0) { + if (!IsCharInStringArray(ios_version, iosVersions)) { + if (android_version_off) { + sb.Append("and "); + } + sb.Append("iOS version("); + sb.Append(ios_version); + sb.Append(") "); + ios_version_off = true; + } + } + if (android_version_off || ios_version_off) { + sb.Append("have been offline, please install the latest version."); + GUILayout.Space(4); + EditorGUILayout.LabelField(sb.ToString(), tipTextStyle); + GUILayout.Space(4); + } else { + sb.Clear(); + } + } + } + + private bool IsCharInStringArray(string character, string[] array) + { + // 遍历数组中的每个字符串 + foreach (string str in array) + { + // 如果当前字符串包含指定的字符,则返回true + if (str == character) + { + return true; + } + } + + // 如果没有找到字符,则返回false + return false; + } + + + private void DrawHeaders(string firstColumnTitle, bool drawAction) + { + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.Space(5); + EditorGUILayout.LabelField(firstColumnTitle, headerLabelStyle, networkWidthOption); + EditorGUILayout.LabelField("Current Version", headerLabelStyle, versionWidthOption); + GUILayout.Space(3); + EditorGUILayout.LabelField("SDK Versions", headerLabelStyle, versionWidthOption); + GUILayout.Space(3); + if (drawAction) + { + GUILayout.FlexibleSpace(); + GUILayout.Button("Actions", headerLabelStyle, fieldWidth); + GUILayout.Space(5); + } + } + + GUILayout.Space(4); + } + + private void DrawPluginDetailRow(string platform, string currentVersion, string sdkversions, string actions) + { + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.Space(5); + EditorGUILayout.LabelField(new GUIContent(platform), networkWidthOption); + EditorGUILayout.LabelField(new GUIContent(currentVersion), versionWidthOption); + GUILayout.Space(3); + EditorGUILayout.LabelField(new GUIContent(sdkversions), versionWidthOption); + GUILayout.Space(3); + // EditorGUILayout.LabelField(new GUIContent(actions), versionWidthOption); + // GUILayout.Space(3); + } + + GUILayout.Space(4); + } + + private void DrawEmptyPluginData(string tip) + { + GUILayout.Space(5); + + // Plugin data failed to load. Show error and retry button. + if (pluginDataLoadFailed) + { + GUILayout.Space(10); + GUILayout.BeginHorizontal(); + GUILayout.Space(5); + EditorGUILayout.LabelField("Failed to load plugin data. Please click retry or restart the integration manager.", titleLabelStyle); + if (GUILayout.Button("Retry", fieldWidth)) + { + pluginDataLoadFailed = false; + loadPluginData(); + } + + GUILayout.Space(5); + GUILayout.EndHorizontal(); + GUILayout.Space(10); + } + // Still loading, show loading label. + else + { + GUILayout.Space(10); + GUILayout.BeginHorizontal(); + // GUILayout.FlexibleSpace(); + EditorGUILayout.LabelField(tip, titleLabelStyle); + // GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + GUILayout.Space(10); + } + + GUILayout.Space(5); + } + //绘制Admob Id + private void DrawAdombAppId() { + var integrationManager = ATIntegrationManager.Instance; + bool isAdmobInstalledForAndroid = integrationManager.isAdmobInstalled(ATConfig.OS_ANDROID); + bool isAdmobInstalledForIos = integrationManager.isAdmobInstalled(ATConfig.OS_IOS); + + if (isAdmobInstalledForAndroid || isAdmobInstalledForIos) { + EditorGUILayout.LabelField("Admob AppId", titleLabelStyle); + GUILayout.Space(5); + using (new EditorGUILayout.VerticalScope("box")) + { + GUILayout.Space(10); + if (isAdmobInstalledForAndroid) { + var androidAdmobAppId = DrawTextField("App ID (Android)", integrationManager.getAdmobAppIdByOs(pluginData, ATConfig.OS_ANDROID), networkWidthOption); + integrationManager.setAdmobAppidByOs(pluginData, ATConfig.OS_ANDROID, androidAdmobAppId); + } + if (isAdmobInstalledForIos) { + if (isAdmobInstalledForAndroid) { + GUILayout.Space(10); + } + var iosAdmobAppId = DrawTextField("App ID (iOS)", integrationManager.getAdmobAppIdByOs(pluginData, ATConfig.OS_IOS), networkWidthOption); + integrationManager.setAdmobAppidByOs(pluginData, ATConfig.OS_IOS, iosAdmobAppId); + } + } + } + } + + private string DrawTextField(string fieldTitle, string text, GUILayoutOption labelWidth, GUILayoutOption textFieldWidthOption = null) + { + GUILayout.BeginHorizontal(); + GUILayout.Space(4); + EditorGUILayout.LabelField(new GUIContent(fieldTitle), labelWidth); + GUILayout.Space(4); + text = (textFieldWidthOption == null) ? GUILayout.TextField(text) : GUILayout.TextField(text, textFieldWidthOption); + GUILayout.Space(4); + GUILayout.EndHorizontal(); + GUILayout.Space(4); + + return text; + } + + + private void DrawMediatedNetworks() + { + GUILayout.Space(5); + EditorGUILayout.LabelField("Ad Networks", titleLabelStyle); + GUILayout.Space(5); + GUILayout.BeginHorizontal(); + using (new EditorGUILayout.VerticalScope("box")) + { + DrawHeaders("Network", true); + string clickTip = "You need to select an sdk version and click the Exchange button."; + // Immediately after downloading and importing a plugin the entire IDE reloads and current versions can be null in that case. Will just show loading text in that case. + if (pluginData == null) + { + ATLog.log("DrawMediatedNetworks failed."); + DrawEmptyPluginData("loading sdk data ..."); + } else if(pluginData.mediatedNetworks == null) { + DrawEmptyPluginData(clickTip); + } else { + var networks = pluginData.mediatedNetworks; + var length = networks.Length; + ATLog.log("DrawMediatedNetworks() >>> networks length: " + length); + if (length == 0) { + DrawEmptyPluginData(clickTip); + return; + } + int versionEmptyLength = 0; + foreach (var network in networks) + { + if (network.isVersionEmpty()) { + // ATLog.log("DrawMediatedNetworks() >>> isVersionEmpty name: " + network.Name); + versionEmptyLength = versionEmptyLength + 1; + } else { + DrawNetworkDetailRow2(network); + } + } + ATLog.log("DrawMediatedNetworks() >>> versionEmptyLength: " + versionEmptyLength); + if (versionEmptyLength == length) { + DrawEmptyPluginData(clickTip); + } + + GUILayout.Space(10); + } + } + + GUILayout.Space(5); + GUILayout.EndHorizontal(); + } + //绘制network的每一行 + private void DrawNetworkDetailRow2(Network network) { + using (new EditorGUILayout.VerticalScope("box")) + { + GUILayout.Space(4); + string a_action = ""; + string i_action = ""; + string cur_a_version = ""; + string cur_i_version = ""; + string last_a_version = ""; + string last_i_version = ""; + if (network.CurrentVersions != null) + { + cur_a_version = network.CurrentVersions.Android; + cur_i_version = network.CurrentVersions.Ios; + } + if (network.LatestVersions != null) + { + last_a_version = network.LatestVersions.Android; + last_i_version = network.LatestVersions.Ios; + } + //Android Action按钮状态 + ATLog.log("DrawNetworkDetailRow2() >>> cur_a_version: " + cur_a_version + " last_i_version: " + last_i_version + + " name: " + network.DisplayName + " last_a_version: " + last_a_version); + if (string.IsNullOrEmpty(cur_a_version)) { + a_action = "Install"; + } else if (ATDataUtil.CompareVersions(cur_a_version, last_a_version) == VersionComparisonResult.Lesser) { + a_action = "Upgrade"; + } else if(ATDataUtil.CompareVersions(cur_a_version, last_a_version) == VersionComparisonResult.Equal) { + a_action = "Installed"; + } + bool hasAndroid = false; + if (!string.IsNullOrEmpty(last_a_version)) { + hasAndroid = true; + DrawRowNetwork(network, ATConfig.OS_ANDROID, cur_a_version, last_a_version, a_action, true); + } + //iOS Action按钮状态 + // var i_compare_result = ATDataUtil.CompareVersions(cur_i_version, last_i_version); + if (string.IsNullOrEmpty(cur_i_version)) { + i_action = "Install"; + } else if (ATDataUtil.CompareVersions(cur_i_version, last_i_version) == VersionComparisonResult.Lesser) { + i_action = "Upgrade"; + } else if(ATDataUtil.CompareVersions(cur_i_version, last_i_version) == VersionComparisonResult.Equal) { + i_action = "Installed"; + } + if (!string.IsNullOrEmpty(last_i_version)) { + DrawRowNetwork(network, ATConfig.OS_IOS, cur_i_version, last_i_version, i_action, !hasAndroid); + } + GUILayout.Space(4); + } + } + + private void DrawRowNetwork(Network network, int os, string curVersion, string lastVersion, string action, bool isShowNetworkName) + { + GUILayout.Space(5); + if (os == ATConfig.OS_ANDROID) { + if (!string.IsNullOrEmpty(curVersion)) { + curVersion = "Android-" + curVersion; + } else { + curVersion = "Not Installed"; + } + lastVersion = "Android-" + lastVersion; + } else { + if (!string.IsNullOrEmpty(curVersion)) { + curVersion = "iOS-" + curVersion; + } else { + curVersion = "Not Installed"; + } + lastVersion = "iOS-" + lastVersion; + } + using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandHeight(false))) + { + GUILayout.Space(5); + if (isShowNetworkName) { + EditorGUILayout.LabelField(new GUIContent(network.DisplayName), networkWidthOption); + } else { + EditorGUILayout.LabelField(new GUIContent(""), networkWidthOption); + } + + EditorGUILayout.LabelField(new GUIContent(curVersion), versionWidthOption); + GUILayout.Space(3); + EditorGUILayout.LabelField(new GUIContent(lastVersion), versionWidthOption); + GUILayout.Space(3); + GUILayout.FlexibleSpace(); + + if (network.isReqiureUpdate()) + { + GUILayout.Label(new GUIContent { image = alertIcon, tooltip = "Adapter not compatible, please update to the latest version." }, iconStyle); + } + + GUI.enabled = action != "Installed"; + if (GUILayout.Button(new GUIContent(action), fieldWidth)) + { + ATIntegrationManager.Instance.networkInstallOrUpdate(pluginData, network, os); + } + GUI.enabled = true; + GUILayout.Space(2); + + GUI.enabled = action == "Installed"; + if (GUILayout.Button(new GUIContent { image = uninstallIcon, tooltip = "Uninstall" }, iconStyle)) + { + EditorUtility.DisplayProgressBar("Integration Manager", "Deleting " + network.Name + "...", 0.5f); + ATIntegrationManager.Instance.uninstallNetwork(network, os); + //Refresh UI + AssetDatabase.Refresh(); + EditorUtility.ClearProgressBar(); + } + + GUI.enabled = true; + GUILayout.Space(5); + } + } + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntegrationManagerWindow.cs.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntegrationManagerWindow.cs.meta new file mode 100644 index 0000000..e3df001 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntegrationManagerWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 435df1e40057948a581aaa9c703eadba +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntergrationHotFix.cs b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntergrationHotFix.cs new file mode 100644 index 0000000..6cede7e --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntergrationHotFix.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Xml.Linq; +using UnityEditor; +using UnityEngine; +using UnityEngine.Networking; +using UnityEditor.PackageManager.Requests; +using UnityEditor.PackageManager; +using System.Threading.Tasks; +using System.Threading; + +namespace AnyThink.Scripts.IntegrationManager.Editor +{ + public class ATIntegrationHotFix { + public static ATIntegrationHotFix Instance = new ATIntegrationHotFix(); + + private ATIntegrationHotFix() + { + + } + + private static string plugin_hot_fix_data_file_name = "plugin_hot_fix_data.json"; + + public void loadHotFixData() + { + var downloadUrl = ATNetInfo.getHotfixPluginDownloadUrl(ATConfig.PLUGIN_VERSION); + ATLog.log("loadHotFixData() >>> downloadUrl: " + downloadUrl); + ATEditorCoroutine.startCoroutine(loadHotFixDataWithIEnumerator(downloadUrl)); + } + + private IEnumerator loadHotFixDataWithIEnumerator(string url) { + var hotFixDataRequest = UnityWebRequest.Get(url); + var webRequest = hotFixDataRequest.SendWebRequest(); + while (!webRequest.isDone) + { + yield return new WaitForSeconds(0.1f); + } + +#if UNITY_2020_1_OR_NEWER + if (hotFixDataRequest.result != UnityWebRequest.Result.Success) +#elif UNITY_2017_2_OR_NEWER + if (hotFixDataRequest.isNetworkError || hotFixDataRequest.isHttpError) +#else + if (hotFixDataRequest.isError) +#endif + { + // Debug.Log("loadPluginData failed."); + // callback(null); + ATLog.log("load hotfix data failed."); + } + else + { + //解析热修复的数据 + try { + string hotFixData = hotFixDataRequest.downloadHandler.text; + var hotFixDataObj = JsonUtility.FromJson(hotFixData); + ATLog.log("loadHotFixDataWithIEnumerator() >>> hotFixData: " + hotFixData); + //判断status是否需要进行热更新 + if (hotFixDataObj.status != 1) { + ATLog.log("loadHotFixDataWithIEnumerator() >>> 热更新被禁止"); + } else { + var localHotFixDataObj = getHotfixPluginData(); + if (localHotFixDataObj == null) { + //本地未曾下载过热更新 + ATLog.log("loadHotFixDataWithIEnumerator() >>> 本地未曾下载过热更新"); + ATEditorCoroutine.startCoroutine(loadHotFixPlugin(hotFixDataObj)); + } else { + var compareVersionResult = ATDataUtil.CompareVersions(localHotFixDataObj.hot_fix_version, hotFixDataObj.hot_fix_version); + ATLog.log("loadHotFixDataWithIEnumerator() >>> compareVersionResult: " + compareVersionResult); + //本地版本比远端版本低,则需要更新 + if (compareVersionResult == VersionComparisonResult.Lesser) { + ATEditorCoroutine.startCoroutine(loadHotFixPlugin(hotFixDataObj)); + } else { + //不需要热更新 + saveHotfixData(hotFixData); + } + } + } + } catch(Exception e) { + ATLog.logError("parseNetworksJson() >>> failed: " + e); + } + } + } + + private IEnumerator loadHotFixPlugin(HotfixPluginData hotFixDataObj) { + var path = Path.Combine(Application.temporaryCachePath, hotFixDataObj.file_name); + ATLog.log("downloadPluginWithEnumerator() >>> path: " + path); +#if UNITY_2017_2_OR_NEWER + var downloadHandler = new DownloadHandlerFile(path); +#else + var downloadHandler = new ATDownloadHandler(path); +#endif + var downloadUrl = hotFixDataObj.download_url; + UnityWebRequest downloadPluginRequest = new UnityWebRequest(downloadUrl) + { method = UnityWebRequest.kHttpVerbGET, + downloadHandler = downloadHandler + }; + +#if UNITY_2017_2_OR_NEWER + var operation = downloadPluginRequest.SendWebRequest(); +#else + var operation = downloadPluginRequest.Send(); +#endif + while (!operation.isDone) + { + yield return new WaitForSeconds(0.1f); // Just wait till downloadPluginRequest is completed. Our coroutine is pretty rudimentary. + if (operation.progress != 1 && operation.isDone) + { + + } + } + +#if UNITY_2020_1_OR_NEWER + if (downloadPluginRequest.result != UnityWebRequest.Result.Success) +#elif UNITY_2017_2_OR_NEWER + if (downloadPluginRequest.isNetworkError || downloadPluginRequest.isHttpError) +#else + if (downloadPluginRequest.isError) +#endif + { + ATLog.log(downloadPluginRequest.error); + } + else + { + AssetDatabase.ImportPackage(path, false); + AssetDatabase.Refresh(); + + string hotFixData = JsonUtility.ToJson(hotFixDataObj); + saveHotfixData(hotFixData); + } + downloadPluginRequest.Dispose(); + downloadPluginRequest = null; + } + + + private void saveHotfixData(string hotfixPluginData) { + var directoryPath = ATConfig.plugin_setting_data_path; + // 确保目标文件夹存在 + if (!Directory.Exists(directoryPath)) + { + // 如果目录不存在,则创建它 + Directory.CreateDirectory(directoryPath); + } + string fullPath = Path.Combine(directoryPath, plugin_hot_fix_data_file_name); + ATLog.log("saveHotfixData() >>> fullPath: " + fullPath + " hotfixPluginData: " + hotfixPluginData); + File.WriteAllText(fullPath, hotfixPluginData); + } + + private HotfixPluginData getHotfixPluginData() { + string fullPath = Path.Combine(ATConfig.plugin_setting_data_path, plugin_hot_fix_data_file_name); + if (!File.Exists(fullPath)) { + return null; + } + string json = File.ReadAllText(fullPath); + if(json == "") { + return null; + } + return JsonUtility.FromJson(json); + } + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntergrationHotFix.cs.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntergrationHotFix.cs.meta new file mode 100644 index 0000000..78e0db3 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATIntergrationHotFix.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9261d30b7b2ae4a469e3428502ab201c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATLog.cs b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATLog.cs new file mode 100644 index 0000000..1f9aca4 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATLog.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections; +using System.IO; +using System.Linq; +using UnityEditor; +using UnityEngine; + +public class ATLog { + public static bool isDebug = false; + + public static void log(string msg) + { + // string msg = + if (isDebug) { + Debug.Log(msg); + } + } + + public static void log(string tag, string msg) + { + if (isDebug) { + Debug.Log(tag + ": " + msg); + } + } + + public static void logFormat(string msg, object[] args) + { + if (isDebug) { + Debug.LogFormat(msg, args); + } + } + + public static void logError(string msg) + { + Debug.LogError(msg); + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATLog.cs.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATLog.cs.meta new file mode 100644 index 0000000..b24bb72 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATLog.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7535cfe4fd8d145fe896ce8d4099d1db +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATMenuItems.cs b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATMenuItems.cs new file mode 100644 index 0000000..579f4da --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATMenuItems.cs @@ -0,0 +1,37 @@ +//菜单栏 +using UnityEditor; +using UnityEngine; +// using DownloadManager; + +namespace AnyThink.Scripts.IntegrationManager.Editor +{ + public class AnyThinkMenuItems : MonoBehaviour + { + /** + * The special characters at the end represent a shortcut for this action. + * + * % - ctrl on Windows, cmd on macOS + * # - shift + * & - alt + * + * So, (shift + cmd/ctrl + t) will launch the integration manager + */ + [MenuItem("ThinkupTpnPlugin/SDK Manager %#t")] + private static void IntegrationManager() + { + + ATIntegrationManagerWindow.ShowManager(); + } + + [MenuItem("ThinkupTpnPlugin/Documentation")] + public static void Documentation() + { + // if (ATConfig.isSelectedChina()) { + // Application.OpenURL("https://help.toponad.com/cn/docs/SDK-dao-ru-shuo-ming"); + // } else { + // Application.OpenURL("https://docs.toponad.com/#/en-us/unity/unity_doc/unity_access_doc_new?id=_3-integration"); + // } + Application.OpenURL("https://help.toponad.com/cn/docs/SDK-dao-ru-shuo-ming"); + } + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATMenuItems.cs.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATMenuItems.cs.meta new file mode 100644 index 0000000..06e6948 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATMenuItems.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fe6ef4ba2bbf2480187401f5626e19a3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATNetInfo.cs b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATNetInfo.cs new file mode 100644 index 0000000..3afc059 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATNetInfo.cs @@ -0,0 +1,39 @@ +using System; +using System.IO; +using System.Collections; +using System.Collections.Generic; + + +using UnityEngine; + +namespace AnyThink.Scripts.IntegrationManager.Editor +{ + public static class ATNetInfo { + //插件的配置文件:unity_plugin_config.json + public static string getPluginConfigUrl(String plugin_version) + { + return "https://topon-sdk-release.oss-cn-hangzhou.aliyuncs.com/Unity_Release_Thinkup_TPN/plugin/" + plugin_version + "/unity_plugin_config.json"; + } + //插件版本对应的network列表文件:unity_plugin_config_network.json + public static string getNetworkListUrl(String plugin_version) + { + return "https://topon-sdk-release.oss-cn-hangzhou.aliyuncs.com/Unity_Release_Thinkup_TPN/plugin/" + plugin_version + "/unity_plugin_config_network.json"; + } + //插件unitypackage名字 + public static string getPluginFileName(string pluginVersion) + { + return "ThinkupTpnPlugin_" + pluginVersion + ".unitypackage"; + } + //插件unitypackage的下载链接 + public static string getPluginDownloadUrl(string pluginVersion) + { + return "https://topon-sdk-release.oss-cn-hangzhou.aliyuncs.com/Unity_Release_Thinkup_TPN/plugin/" + pluginVersion + "/" + getPluginFileName(pluginVersion); + } + + public static string getHotfixPluginDownloadUrl(string pluginVersion) + { + return "https://topon-sdk-release.oss-cn-hangzhou.aliyuncs.com/Unity_Release_Thinkup_TPN/plugin/" + pluginVersion + "/hotfix/hotfix_config.json"; + } + } + +} diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATNetInfo.cs.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATNetInfo.cs.meta new file mode 100644 index 0000000..7490af4 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATNetInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bf2e8a6c6aabc44329d491a7c9709e33 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATPluginLocalDataModel.cs b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATPluginLocalDataModel.cs new file mode 100644 index 0000000..95489ec --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATPluginLocalDataModel.cs @@ -0,0 +1,220 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Xml.Linq; +using UnityEditor; +using UnityEngine; +using UnityEngine.Networking; + +namespace AnyThink.Scripts.IntegrationManager.Editor +{ + [Serializable] + public class PluginData + { + public string pluginVersion; //插件版本 + public string[] androidVersions; + public string[] iosVersions; + public int country = ATConfig.getDefCountry(); //默认是1=china + public Network anyThink; + public Network[] mediatedNetworks; + public PluginSettingData pluginSettingData; + public NetworkRequestParams requestParams; + } + //请求network参数 + public class NetworkRequestParams { + public int os; + public string androidVersion; + public string iosVersion; + } + + [Serializable] + public class Network : IComparable + { + // + // Sample network data: + // + // { + // "Name": "adcolony", + // "DisplayName": "AdColony", + // "DownloadUrl": "https://bintray.com/applovin/Unity-Mediation-Packages/download_file?file_path=AppLovin-AdColony-Adapters-Android-3.3.10.1-iOS-3.3.7.2.unitypackage", + // "PluginFileName": "AppLovin-AdColony-Adapters-Android-3.3.10.1-iOS-3.3.7.2.unitypackage", + // "DependenciesFilePath": "MaxSdk/Mediation/AdColony/Editor/Dependencies.xml", + // "LatestVersions" : { + // "Unity": "android_3.3.10.1_ios_3.3.7.2", + // "Android": "3.3.10.1", + // "Ios": "3.3.7.2" + // } + // } + // + + public string Name; + public string DisplayName; + public string AndroidDownloadUrl; + public string iOSDownloadloadUrl; + // public string DependenciesFilePath; + public string PluginFileName; + public int Country; + public Versions LatestVersions; //最新版本 + public Versions CurrentVersions; //当前版本 + [NonSerialized] public VersionComparisonResult CurrentToLatestVersionComparisonResult = VersionComparisonResult.Equal; + // [NonSerialized] public bool RequiresUpdate = CurrentToLatestVersionComparisonResult == VersionComparisonResult.Lesser; + + public bool isVersionEmpty() { + if (LatestVersions != null) { + ATLog.log("isVersionEmpty() >>> name: " + Name + " android: " + LatestVersions.Android + " ios: " + LatestVersions.Ios); + return string.IsNullOrEmpty(LatestVersions.Android) && string.IsNullOrEmpty(LatestVersions.Ios); + } + return false; + } + + public bool isReqiureUpdate() + { + return CurrentToLatestVersionComparisonResult == VersionComparisonResult.Lesser; + } + + public int CompareTo(Network other) + { + return this.DisplayName.CompareTo(other.DisplayName); + } + + public string ToString() { + return DisplayName + "-" + AndroidDownloadUrl + "-" + iOSDownloadloadUrl + "-" + Country; + } + } + + /// + /// A helper data class used to get current versions from Dependency.xml files. + /// + [Serializable] + public class Versions + { + + public string Unity; + + public string Android; + + public string Ios; + + public override bool Equals(object value) + { + var versions = value as Versions; + + return versions != null + && (Unity == null || Unity.Equals(versions.Unity)) + && (Android == null || Android.Equals(versions.Android)) + && (Ios == null || Ios.Equals(versions.Ios)); + } + + public bool HasEqualSdkVersions(Versions versions) + { + return versions != null && versions.Android == Android && versions.Ios == Ios; + } + + public override int GetHashCode() + { + return new { Unity, Android, Ios }.GetHashCode(); + } + + public Versions clone() + { + Versions cloneObj = new Versions(); + cloneObj.Android = Android; + cloneObj.Ios = Ios; + cloneObj.Unity = Unity; + + return cloneObj; + } + } + + public enum VersionComparisonResult + { + Lesser = -1, + Equal = 0, + Greater = 1 + } + + //存在本地插件设置数据并序列化为json文件 + [Serializable] + public class PluginSettingData + { + public int curCountry = ATConfig.getDefCountry(); //当前选择的国家 + + public CountrySettingData china = new CountrySettingData(ATConfig.CHINA_COUNTRY); //国内地区 + public CountrySettingData nonchina = new CountrySettingData(ATConfig.NONCHINA_COUNTRY); //海外地区 + + public CountrySettingData getCountrySettingData() { + if (curCountry == ATConfig.CHINA_COUNTRY) { + return china; + } else { + return nonchina; + } + } + + //Android 是否同时安装了国内海外地区 + public bool isBothInstallAndroid() { + return !string.IsNullOrEmpty(china.android_version) && !string.IsNullOrEmpty(nonchina.android_version); + } + + //iOS 是否同时安装了国内海外地区 + public bool isBothInstallIOS() { + return !string.IsNullOrEmpty(china.ios_version) && !string.IsNullOrEmpty(nonchina.ios_version); + } + } + //已安装的sdk版本 + [Serializable] + public class CountrySettingData + { + + public string android_version; //当前已安装Android sdk的版本号 + + public string ios_version; //当前已安装的iOS sdk的版本号 + + public int androidXSetting = 0; //当前的AndroidX设置,0=default; 1=修改为AndroidX;2=修改为非AndroidX + + public int country; + + public string android_admob_app_id; + public string ios_admob_app_id; + + public CountrySettingData(int country) { + this.country = country; + } + + public string getAdmobAppId(int os) { + if (os == ATConfig.OS_ANDROID) { + return android_admob_app_id; + } else { + return ios_admob_app_id; + } + } + + public void setAdmobAppId(string appId, int os) { + if (os == ATConfig.OS_ANDROID) { + android_admob_app_id = appId; + } else { + ios_admob_app_id = appId; + } + } + } + //存储在本地的Network json数据 + [Serializable] + public class NetworkLocalData + { + public string name; + public string version; + public int country; + public string path; + } + + [Serializable] + public class HotfixPluginData + { + public string plugin_version; + public string hot_fix_version; + public string download_url; + public int status; + public string file_name; + } +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATPluginLocalDataModel.cs.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATPluginLocalDataModel.cs.meta new file mode 100644 index 0000000..50481cb --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATPluginLocalDataModel.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9a01fc414249b4d609e2db2ea9cc1876 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATSdkUtil.cs b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATSdkUtil.cs new file mode 100644 index 0000000..f1e1cdd --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATSdkUtil.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using UnityEngine; +// #if UNITY_EDITOR //是Unity编辑器才引入 +using UnityEditor; +// #endif + + +public class ATSdkUtil +{ +// #if UNITY_EDITOR + /// + /// Gets the path of the asset in the project for a given Anythink plugin export path. + /// + /// The actual exported path of the asset. + /// The exported path of the MAX plugin asset or the default export path if the asset is not found. + public static string GetAssetPathForExportPath(string exportPath) + { + var defaultPath = Path.Combine("Assets", exportPath); + var assetLabelToFind = "l:al_max_export_path-" + exportPath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); + var assetGuids = AssetDatabase.FindAssets(assetLabelToFind); + + return assetGuids.Length < 1 ? defaultPath : AssetDatabase.GUIDToAssetPath(assetGuids[0]); + } + + public static bool Exists(string filePath) + { + return Directory.Exists(filePath) || File.Exists(filePath); + } +// #endif +} \ No newline at end of file diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATSdkUtil.cs.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATSdkUtil.cs.meta new file mode 100644 index 0000000..1984a27 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/ATSdkUtil.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f128e7cd9651c48e5939333cccd9e821 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/AnyThinkPlugin.IntegrationManager.Editor.asmdef b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/AnyThinkPlugin.IntegrationManager.Editor.asmdef new file mode 100644 index 0000000..5e23bc8 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/AnyThinkPlugin.IntegrationManager.Editor.asmdef @@ -0,0 +1,10 @@ +{ + "name": "ThinkupTpnPlugin.Script.IntegrationManager.Editor", + "references": [ + "ThinkupTpnPlugin.Script" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [] +} diff --git a/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/AnyThinkPlugin.IntegrationManager.Editor.asmdef.meta b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/AnyThinkPlugin.IntegrationManager.Editor.asmdef.meta new file mode 100644 index 0000000..98c60f2 --- /dev/null +++ b/Assets/ThinkupTpnPlugin/Script/IntegrationManager/Editor/AnyThinkPlugin.IntegrationManager.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d9801a1b5d6474105846c4dc70b24ef3 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: