You've already forked Commercialization.topon
update core
This commit is contained in:
233
Assets/AnyThinkAds/Platform/iOS/ATSplashAdClient.cs
Normal file
233
Assets/AnyThinkAds/Platform/iOS/ATSplashAdClient.cs
Normal file
@@ -0,0 +1,233 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AnyThinkAds.Common;
|
||||
using AnyThinkAds.Api;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
|
||||
|
||||
namespace AnyThinkAds.iOS {
|
||||
|
||||
public class ATSplashAdClient : IATSplashAdClient {
|
||||
private ATSplashAdListener anyThinkListener;
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdShowEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdShowFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdClickEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
|
||||
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
|
||||
public event EventHandler<ATAdEventArgs> onAdLoadTimeoutEvent;
|
||||
public event EventHandler<ATAdEventArgs> onDeeplinkEvent;
|
||||
public event EventHandler<ATAdEventArgs> onDownloadConfirmEvent;
|
||||
|
||||
public void addsetting(string placementId,string json){
|
||||
//todo...
|
||||
}
|
||||
|
||||
public void setListener(ATSplashAdListener listener) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::setListener()");
|
||||
anyThinkListener = listener;
|
||||
}
|
||||
|
||||
public void loadSplashAd(string placementId, int fetchAdTimeout, string defaultAdSourceConfig, string mapJson) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::loadSplashAd()");
|
||||
ATSplashAdWrapper.setClientForPlacementID(placementId, this);
|
||||
ATSplashAdWrapper.loadSplashAd(placementId, mapJson);
|
||||
}
|
||||
|
||||
public bool hasSplashAdReady(string placementId) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::hasSplashAdReady()");
|
||||
return ATSplashAdWrapper.hasSplashAdReady(placementId);
|
||||
}
|
||||
|
||||
public void showSplashAd(string placementId, string mapJson) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::showSplashAd()");
|
||||
ATSplashAdWrapper.showSplashAd(placementId, mapJson);
|
||||
}
|
||||
|
||||
public void cleanCache(string placementId) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::cleanCache()");
|
||||
ATSplashAdWrapper.clearCache(placementId);
|
||||
}
|
||||
|
||||
public string checkAdStatus(string placementId) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::checkAdStatus()");
|
||||
return ATSplashAdWrapper.checkAdStatus(placementId);
|
||||
}
|
||||
|
||||
public string getValidAdCaches(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::getValidAdCaches()");
|
||||
return ATSplashAdWrapper.getValidAdCaches(placementId);
|
||||
}
|
||||
|
||||
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
|
||||
Debug.Log("Unity: ATSplashAdAdClient::entryScenarioWithPlacementID()");
|
||||
ATSplashAdWrapper.entryScenarioWithPlacementID(placementId,scenarioID);
|
||||
}
|
||||
|
||||
|
||||
//Callbacks
|
||||
public void OnSplashAdDeeplink(string placementID, String callbackJson, bool isSuccess) {
|
||||
onDeeplinkEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson, false, isSuccess));
|
||||
}
|
||||
|
||||
public void OnSplashAdLoadTimeout(string placementID) {
|
||||
Debug.Log("OnSplashAdLoadTimeout...unity3d.");
|
||||
onAdLoadTimeoutEvent?.Invoke(this, new ATAdEventArgs(placementID, "", true));
|
||||
}
|
||||
|
||||
public void OnSplashAdLoaded(string placementID) {
|
||||
Debug.Log("onSplashAdLoaded...unity3d.");
|
||||
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementID));
|
||||
}
|
||||
|
||||
public void OnSplashAdLoadFailure(string placementID, string code, string error) {
|
||||
Debug.Log("onSplashAdFailed...unity3d.");
|
||||
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, code, error));
|
||||
}
|
||||
|
||||
public void OnSplashAdVideoPlayFailure(string placementID, string code, string error) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::OnSplashAdVideoPlayFailure()");
|
||||
onAdVideoFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, code, error));
|
||||
}
|
||||
|
||||
public void OnSplashAdVideoPlayStart(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::OnSplashAdPlayStart()");
|
||||
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
public void OnSplashAdVideoPlayEnd(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::OnSplashAdVideoPlayEnd()");
|
||||
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
public void OnSplashAdShow(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::OnSplashAdShow()");
|
||||
onAdShowEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
public void OnSplashAdFailedToShow(string placementID) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::OnSplashAdFailedToShow()");
|
||||
onAdShowFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, "-1", "Failed to show video ad"));
|
||||
}
|
||||
|
||||
public void OnSplashAdClick(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::OnSplashAdClick()");
|
||||
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
public void OnSplashAdClose(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::OnSplashAdClose()");
|
||||
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
|
||||
}
|
||||
|
||||
//auto callbacks
|
||||
public void startLoadingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::startLoadingADSource()");
|
||||
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void finishLoadingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::finishLoadingADSource()");
|
||||
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void failToLoadADSource(string placementId, string callbackJson,string code, string error)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::failToLoadADSource()");
|
||||
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
public void startBiddingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::startBiddingADSource()");
|
||||
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void finishBiddingADSource(string placementId, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::finishBiddingADSource()");
|
||||
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
|
||||
}
|
||||
public void failBiddingADSource(string placementId,string callbackJson, string code, string error)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::failBiddingADSource()");
|
||||
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
|
||||
}
|
||||
|
||||
// Auto
|
||||
public void addAutoLoadAdPlacementID(string[] placementIDList)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient:addAutoLoadAdPlacementID()");
|
||||
|
||||
|
||||
|
||||
if (placementIDList != null && placementIDList.Length > 0)
|
||||
{
|
||||
foreach (string placementID in placementIDList)
|
||||
{
|
||||
ATSplashAdWrapper.setClientForPlacementID(placementID, this);
|
||||
}
|
||||
|
||||
string placementIDListString = JsonMapper.ToJson(placementIDList);
|
||||
ATSplashAdWrapper.addAutoLoadAdPlacementID(placementIDListString);
|
||||
Debug.Log("addAutoLoadAdPlacementID, placementIDList === " + placementIDListString);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("addAutoLoadAdPlacementID, placementIDList = null");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void removeAutoLoadAdPlacementID(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient:removeAutoLoadAdPlacementID()");
|
||||
ATSplashAdWrapper.removeAutoLoadAdPlacementID(placementId);
|
||||
}
|
||||
|
||||
public bool autoLoadSplashAdReadyForPlacementID(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient:autoLoadSplashAdReadyForPlacementID()");
|
||||
return ATSplashAdWrapper.autoLoadSplashAdReadyForPlacementID(placementId);
|
||||
}
|
||||
public string getAutoValidAdCaches(string placementId)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient:getAutoValidAdCaches()");
|
||||
return ATSplashAdWrapper.getAutoValidAdCaches(placementId);
|
||||
}
|
||||
|
||||
public string checkAutoAdStatus(string placementId) {
|
||||
Debug.Log("Unity: ATSplashAdAdClient::checkAutoAdStatus()");
|
||||
return ATSplashAdWrapper.checkAutoAdStatus(placementId);
|
||||
}
|
||||
|
||||
|
||||
public void setAutoLocalExtra(string placementId, string mapJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient:setAutoLocalExtra()");
|
||||
ATSplashAdWrapper.setAutoLocalExtra(placementId, mapJson);
|
||||
}
|
||||
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient:entryAutoAdScenarioWithPlacementID()");
|
||||
ATSplashAdWrapper.entryAutoAdScenarioWithPlacementID(placementId, scenarioID);
|
||||
}
|
||||
public void showAutoAd(string placementId, string mapJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdAdClient::showAutoAd()");
|
||||
ATSplashAdWrapper.showAutoSplashAd(placementId, mapJson);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/AnyThinkAds/Platform/iOS/ATSplashAdClient.cs.meta
Normal file
11
Assets/AnyThinkAds/Platform/iOS/ATSplashAdClient.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff13e06039d104e3e9c3cb155b8f4ecd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4787b4f73b23449fa906f342dfca1d00
|
||||
guid: 71c4a563eff03483d8d19430791ee6f8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd4b39134d1e64f1c9672717d4878e58
|
||||
guid: 304162e40b68148bb94a0c8806efce99
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
||||
@@ -123,13 +123,13 @@ static NSString *kATBannerAdLoadingExtraInlineAdaptiveOrientationKey = @"inline_
|
||||
statusDict[@"isReady"] = @(checkLoadModel.isReady);
|
||||
statusDict[@"adInfo"] = checkLoadModel.adOfferInfo;
|
||||
NSLog(@"ATBannerAdWrapper::statusDict = %@", statusDict);
|
||||
return statusDict.jsonString;
|
||||
return statusDict.jsonFilterString;
|
||||
}
|
||||
|
||||
-(NSString*) getValidAdCaches:(NSString *)placementID {
|
||||
NSArray *array = [[ATAdManager sharedManager] getBannerValidAdsForPlacementID:placementID];
|
||||
NSLog(@"ATNativeAdWrapper::array = %@", array);
|
||||
return array.jsonString;
|
||||
return array.jsonFilterString;
|
||||
}
|
||||
|
||||
UIEdgeInsets SafeAreaInsets_ATUnityBanner() {
|
||||
|
||||
@@ -70,6 +70,25 @@
|
||||
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] isMemberOfClass:[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"];
|
||||
|
||||
@@ -108,7 +108,7 @@ static NSString *kATInterstitialSizeUsesPixelFlagKey = @"uses_pixel";
|
||||
-(NSString*) getValidAdCaches:(NSString *)placementID {
|
||||
NSArray *array = [[ATAdManager sharedManager] getInterstitialValidAdsForPlacementID:placementID];
|
||||
NSLog(@"ATNativeAdWrapper::array = %@", array);
|
||||
return array.jsonString;
|
||||
return array.jsonFilterString;
|
||||
}
|
||||
|
||||
-(void) showInterstitialAdWithPlacementID:(NSString*)placementID extraJsonString:(NSString*)extraJsonString {
|
||||
@@ -123,7 +123,7 @@ static NSString *kATInterstitialSizeUsesPixelFlagKey = @"uses_pixel";
|
||||
statusDict[@"isReady"] = @(checkLoadModel.isReady);
|
||||
statusDict[@"adInfo"] = checkLoadModel.adOfferInfo;
|
||||
NSLog(@"ATInterstitialAdWrapper::statusDict = %@", statusDict);
|
||||
return statusDict.jsonString;
|
||||
return statusDict.jsonFilterString;
|
||||
}
|
||||
- (void)entryScenarioWithPlacementID:(NSString *)placementID scenarioID:(NSString *)scenarioID{
|
||||
|
||||
@@ -177,7 +177,7 @@ static NSString *kATInterstitialSizeUsesPixelFlagKey = @"uses_pixel";
|
||||
|
||||
NSLog(@"Unity: getAutoValidAdCaches::array = %@", array);
|
||||
|
||||
return array.jsonString;
|
||||
return array.jsonFilterString;
|
||||
}
|
||||
|
||||
-(NSString*) checkAutoAdStatus:(NSString *)placementID {
|
||||
@@ -190,7 +190,7 @@ static NSString *kATInterstitialSizeUsesPixelFlagKey = @"uses_pixel";
|
||||
statusDict[@"adInfo"] = checkLoadModel.adOfferInfo;
|
||||
|
||||
NSLog(@":checkAutoAdStatus statusDict = %@", statusDict);
|
||||
return statusDict.jsonString;
|
||||
return statusDict.jsonFilterString;
|
||||
}
|
||||
|
||||
-(void) setAutoLocalExtra:(NSString*)placementID customDataJSONString:(NSString*)customDataJSONString{
|
||||
|
||||
@@ -150,7 +150,7 @@ UIEdgeInsets SafeAreaInsets_ATUnityNative() {
|
||||
statusDict[@"isReady"] = @(checkLoadModel.isReady);
|
||||
statusDict[@"adInfo"] = checkLoadModel.adOfferInfo;
|
||||
NSLog(@"ATNativeAdWrapper::statusDict = %@", statusDict);
|
||||
return statusDict.jsonString;
|
||||
return statusDict.jsonFilterString;
|
||||
}
|
||||
- (void)entryScenarioWithPlacementID:(NSString *)placementID scenarioID:(NSString *)scenarioID{
|
||||
|
||||
@@ -160,7 +160,7 @@ UIEdgeInsets SafeAreaInsets_ATUnityNative() {
|
||||
-(NSString*) getValidAdCaches:(NSString *)placementID {
|
||||
NSArray *array = [[ATAdManager sharedManager] getNativeValidAdsForPlacementID:placementID];
|
||||
NSLog(@"ATNativeAdWrapper::array = %@", array);
|
||||
return array.jsonString;
|
||||
return array.jsonFilterString;
|
||||
}
|
||||
|
||||
-(void) showNativeAdWithPlacementID:(NSString*)placementID metricsJSONString:(NSString*)metricsJSONString extraJsonString:(NSString*)extraJsonString {
|
||||
@@ -286,15 +286,17 @@ UIEdgeInsets SafeAreaInsets_ATUnityNative() {
|
||||
|
||||
NSMutableArray *array = [@[selfRenderView.iconImageView,selfRenderView.titleLabel,selfRenderView.textLabel,selfRenderView.ctaLabel,selfRenderView.mainImageView] mutableCopy];
|
||||
|
||||
if (mediaView) {
|
||||
if (mediaView && offer.nativeAd.isVideoContents) {
|
||||
[array addObject:mediaView];
|
||||
|
||||
selfRenderView.mediaView = mediaView;
|
||||
[selfRenderView addSubview:mediaView];
|
||||
//避免被遮挡
|
||||
[selfRenderView bringSubviewToFront:selfRenderView.logoImageView];
|
||||
}
|
||||
|
||||
[nativeADView registerClickableViewArray:array];
|
||||
|
||||
selfRenderView.mediaView = mediaView;
|
||||
|
||||
[selfRenderView addSubview:mediaView];
|
||||
|
||||
|
||||
self.adView = nativeADView;
|
||||
|
||||
@@ -182,7 +182,7 @@
|
||||
self.textLabel.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
-(void) configureMetrics:(NSDictionary *)metrics {
|
||||
NSDictionary<NSString*, UIView*> *views = @{kNativeAssetTitle:_titleLabel, kNativeAssetText:_textLabel, kNativeAssetCta:_ctaLabel, kNativeAssetRating:_ratingLabel, kNativeAssetAdvertiser:_advertiserLabel, kNativeAssetIcon:_iconImageView, kNativeAssetMainImage:_mainImageView, kNativeAssetDislike:_dislikeButton};
|
||||
NSDictionary<NSString*, UIView*> *views = @{kNativeAssetTitle:_titleLabel, kNativeAssetText:_textLabel, kNativeAssetCta:_ctaLabel, kNativeAssetRating:_ratingLabel, kNativeAssetAdvertiser:_advertiserLabel, kNativeAssetIcon:_iconImageView, kNativeAssetMainImage:_mainImageView, kNativeAssetSponsorImage:_logoImageView, 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];
|
||||
|
||||
@@ -101,13 +101,13 @@ NSString *const kLoadExtraMediaExtraKey = @"UserExtraData";
|
||||
statusDict[@"isReady"] = @(checkLoadModel.isReady);
|
||||
statusDict[@"adInfo"] = checkLoadModel.adOfferInfo;
|
||||
NSLog(@"ATRewardedVideoWrapper::statusDict = %@", statusDict);
|
||||
return statusDict.jsonString;
|
||||
return statusDict.jsonFilterString;
|
||||
}
|
||||
|
||||
-(NSString*) getValidAdCaches:(NSString *)placementID {
|
||||
NSArray *array = [[ATAdManager sharedManager] getRewardedVideoValidAdsForPlacementID:placementID];
|
||||
NSLog(@"ATNativeAdWrapper::array = %@", array);
|
||||
return array.jsonString;
|
||||
return array.jsonFilterString;
|
||||
}
|
||||
|
||||
-(void) showRewardedVideoWithPlacementID:(NSString*)placementID extraJsonString:(NSString*)extraJsonString {
|
||||
@@ -177,7 +177,7 @@ NSString *const kLoadExtraMediaExtraKey = @"UserExtraData";
|
||||
-(NSString*) getAutoValidAdCaches:(NSString *)placementID{
|
||||
NSArray *array = [[ATRewardedVideoAutoAdManager sharedInstance] checkValidAdCachesWithPlacementID:placementID];
|
||||
NSLog(@"Unity: getAutoValidAdCaches::array = %@", array);
|
||||
return array.jsonString;
|
||||
return array.jsonFilterString;
|
||||
}
|
||||
|
||||
-(NSString*) checkAutoAdStatus:(NSString *)placementID {
|
||||
@@ -187,7 +187,7 @@ NSString *const kLoadExtraMediaExtraKey = @"UserExtraData";
|
||||
statusDict[@"isReady"] = @(checkLoadModel.isReady);
|
||||
statusDict[@"adInfo"] = checkLoadModel.adOfferInfo;
|
||||
NSLog(@"ATRewardedVideoWrapper::checkAutoAdStatus statusDict = %@", statusDict);
|
||||
return statusDict.jsonString;
|
||||
return statusDict.jsonFilterString;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// ATSplashAdWrapper.h
|
||||
// UnityFramework
|
||||
//
|
||||
// Created by li zhixuan on 2023/5/4.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "ATBaseUnityWrapper.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface ATSplashAdWrapper : ATBaseUnityWrapper
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b3d7c39097da4302b4de8c9415a5f44
|
||||
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:
|
||||
243
Assets/AnyThinkAds/Platform/iOS/Internal/C/ATSplashAdWrapper.m
Normal file
243
Assets/AnyThinkAds/Platform/iOS/Internal/C/ATSplashAdWrapper.m
Normal file
@@ -0,0 +1,243 @@
|
||||
//
|
||||
// ATSplashAdWrapper.m
|
||||
// UnityFramework
|
||||
//
|
||||
// Created by li zhixuan on 2023/5/4.
|
||||
//
|
||||
|
||||
#import "ATSplashAdWrapper.h"
|
||||
#import "ATUnityUtilities.h"
|
||||
#import <AnyThinkSplash/AnyThinkSplash.h>
|
||||
|
||||
@interface ATSplashAdWrapper () <ATSplashDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation ATSplashAdWrapper
|
||||
|
||||
+ (instancetype)sharedInstance {
|
||||
static ATSplashAdWrapper *sharedInstance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [[ATSplashAdWrapper alloc] init];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
- (NSString *)scriptWrapperClass {
|
||||
return @"ATSplashAdWrapper";
|
||||
}
|
||||
|
||||
- (id)selWrapperClassWithDict:(NSDictionary *)dict callback:(void(*)(const char*, const char*))callback {
|
||||
NSString *selector = dict[@"selector"];
|
||||
NSArray<NSString*>* arguments = dict[@"arguments"];
|
||||
NSString *firstObject = @"";
|
||||
NSString *lastObject = @"";
|
||||
if (![ATUnityUtilities isEmpty:arguments]) {
|
||||
for (int i = 0; i < arguments.count; i++) {
|
||||
if (i == 0) { firstObject = arguments[i]; }
|
||||
else { lastObject = arguments[i]; }
|
||||
}
|
||||
}
|
||||
|
||||
if ([selector isEqualToString:@"loadSplashAdWithPlacementID:customDataJSONString:callback:"]) {
|
||||
[self loadSplashAdWithPlacementID:firstObject customDataJSONString:lastObject callback:callback];
|
||||
} else if ([selector isEqualToString:@"splashAdReadyForPlacementID:"]) {
|
||||
return [NSNumber numberWithBool:[self splashAdReadyForPlacementID:firstObject]];
|
||||
} else if ([selector isEqualToString:@"showSplashAdWithPlacementID:extraJsonString:"]) {
|
||||
[self showSplashAdWithPlacementID:firstObject extraJsonString:lastObject];
|
||||
} else if ([selector isEqualToString:@"checkAdStatus:"]) {
|
||||
return [self checkAdStatus:firstObject];
|
||||
} else if ([selector isEqualToString:@"clearCache"]) {
|
||||
[self clearCache];
|
||||
} else if ([selector isEqualToString:@"getValidAdCaches:"]) {
|
||||
return [self getValidAdCaches:firstObject];
|
||||
}else if ([selector isEqualToString:@"entryScenarioWithPlacementID:scenarioID:"]) {
|
||||
[self entryScenarioWithPlacementID:firstObject scenarioID:lastObject];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)loadSplashAdWithPlacementID:(NSString*)placementID customDataJSONString:(NSString*)customDataJSONString callback:(void(*)(const char*, const char*))callback {
|
||||
|
||||
[self setCallBack:callback forKey:placementID];
|
||||
NSMutableDictionary *extra = [NSMutableDictionary dictionary];
|
||||
if ([customDataJSONString isKindOfClass:[NSString class]] && [customDataJSONString length] > 0) {
|
||||
NSDictionary *extraDict = [NSJSONSerialization JSONObjectWithData:[customDataJSONString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];
|
||||
[extra addEntriesFromDictionary:extraDict];
|
||||
}
|
||||
NSString *defaultAdSourceConfig = extra[@"default_adSource_config"];
|
||||
NSLog(@"ATSplashAdWrapper::extra = %@", extra);
|
||||
[[ATAdManager sharedManager] loadADWithPlacementID:placementID
|
||||
extra:extra
|
||||
delegate:self
|
||||
containerView:nil
|
||||
defaultAdSourceConfig:defaultAdSourceConfig];
|
||||
}
|
||||
|
||||
|
||||
- (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.anythink.Unity3DPackage" code:100001 userInfo:@{NSLocalizedDescriptionKey:@"AT has failed to load ad", NSLocalizedFailureReasonErrorKey:@"AT has failed to load ad"}];
|
||||
[self invokeCallback:@"OnSplashAdLoadFailure" placementID:placementID error:error extra:nil];
|
||||
|
||||
}
|
||||
|
||||
/// Ad start load
|
||||
- (void)didStartLoadingADSourceWithPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary*)extra {
|
||||
[self invokeCallback:@"startLoadingADSource" placementID:placementID error:nil extra:extra];
|
||||
|
||||
}
|
||||
/// Ad load success
|
||||
- (void)didFinishLoadingADSourceWithPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary*)extra {
|
||||
[self invokeCallback:@"finishLoadingADSource" placementID:placementID error:nil extra:extra];
|
||||
|
||||
}
|
||||
/// Ad load fail
|
||||
- (void)didFailToLoadADSourceWithPlacementID:(NSString*)placementID
|
||||
extra:(NSDictionary*)extra
|
||||
error:(NSError*)error {
|
||||
[self invokeCallback:@"failToLoadADSource" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
/// Ad start bidding
|
||||
- (void)didStartBiddingADSourceWithPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary*)extra {
|
||||
[self invokeCallback:@"startBiddingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
/// Ad bidding success
|
||||
- (void)didFinishBiddingADSourceWithPlacementID:(NSString *)placementID
|
||||
extra:(NSDictionary*)extra {
|
||||
[self invokeCallback:@"finishBiddingADSource" placementID:placementID error:nil extra:extra];
|
||||
}
|
||||
|
||||
/// Ad bidding fail
|
||||
- (void)didFailBiddingADSourceWithPlacementID:(NSString*)placementID
|
||||
extra:(NSDictionary*)extra
|
||||
error:(NSError*)error {
|
||||
[self invokeCallback:@"failBiddingADSource" placementID:placementID error:error extra:extra];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d17f3acf1ffb4fa9abed493f1c1623b
|
||||
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:
|
||||
@@ -12,17 +12,28 @@ 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)
|
||||
|
||||
@@ -13,6 +13,9 @@ NSString *const kATUnityUtilitiesRewardedVideoImpressionNotification = @"kATUnit
|
||||
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));
|
||||
@@ -37,6 +40,41 @@ NSString *const kATUnityUtilitiesAdShowingExtraScenarioKey = @"Scenario";
|
||||
}
|
||||
}
|
||||
|
||||
- (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];
|
||||
}
|
||||
|
||||
@try {
|
||||
jsonData = [NSJSONSerialization dataWithJSONObject:extraDictM
|
||||
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];
|
||||
}
|
||||
@@ -61,6 +99,46 @@ NSString *const kATUnityUtilitiesAdShowingExtraScenarioKey = @"Scenario";
|
||||
}
|
||||
}
|
||||
|
||||
- (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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 299bd02f216b54e2db98218be4653d60
|
||||
guid: 2e059c89366e24ea9ad9a677576c896a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using AOT;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
using AnyThinkAds.iOS;
|
||||
#pragma warning disable 0109
|
||||
public class ATSplashAdWrapper:ATAdWrapper {
|
||||
static private Dictionary<string, ATSplashAdClient> clients;
|
||||
static private string CMessaageReceiverClass = "ATSplashAdWrapper";
|
||||
|
||||
static public new void InvokeCallback(JsonData jsonData) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::InvokeCallback()");
|
||||
string extraJson = "";
|
||||
string callback = (string)jsonData["callback"];
|
||||
Dictionary<string, object> msgDict = JsonMapper.ToObject<Dictionary<string, object>>(jsonData["msg"].ToJson());
|
||||
JsonData msgJsonData = jsonData["msg"];
|
||||
IDictionary idic = (System.Collections.IDictionary)msgJsonData;
|
||||
|
||||
if (idic.Contains("extra")) {
|
||||
JsonData extraJsonDate = msgJsonData["extra"];
|
||||
if (extraJsonDate != null) {
|
||||
extraJson = msgJsonData["extra"].ToJson();
|
||||
}
|
||||
}
|
||||
|
||||
if (callback.Equals("OnSplashAdLoaded")) {
|
||||
OnSplashAdLoaded((string)msgDict["placement_id"]);
|
||||
} else if (callback.Equals("OnSplashAdLoadFailure")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
OnSplashAdLoadFailure((string)msgDict["placement_id"], errorDict);
|
||||
} else if (callback.Equals("OnSplashAdVideoPlayFailure")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg.ContainsKey("code")) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg.ContainsKey("reason")) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
OnSplashAdVideoPlayFailure((string)msgDict["placement_id"], errorDict);
|
||||
} else if (callback.Equals("OnSplashAdVideoPlayStart")) {
|
||||
OnSplashAdVideoPlayStart((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnSplashAdVideoPlayEnd")) {
|
||||
OnSplashAdVideoPlayEnd((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnSplashAdShow")) {
|
||||
OnSplashAdShow((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnSplashAdClick")) {
|
||||
OnSplashAdClick((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnSplashAdClose")) {
|
||||
OnSplashAdClose((string)msgDict["placement_id"], extraJson);
|
||||
} else if (callback.Equals("OnSplashAdFailedToShow")) {
|
||||
OnSplashAdFailedToShow((string)msgDict["placement_id"]);
|
||||
}else if (callback.Equals("startLoadingADSource")) {
|
||||
StartLoadingADSource((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("finishLoadingADSource")) {
|
||||
FinishLoadingADSource((string)msgDict["placement_id"], extraJson);
|
||||
}else if (callback.Equals("failToLoadADSource")) {
|
||||
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
FailToLoadADSource((string)msgDict["placement_id"],extraJson, errorDict);
|
||||
|
||||
}else if (callback.Equals("startBiddingADSource")) {
|
||||
StartBiddingADSource((string)msgDict["placement_id"], extraJson);
|
||||
|
||||
}else if (callback.Equals("finishBiddingADSource")) {
|
||||
FinishBiddingADSource((string)msgDict["placement_id"], extraJson);
|
||||
|
||||
}else if (callback.Equals("failBiddingADSource")) {
|
||||
Dictionary<string, object> errorDict = new Dictionary<string, object>();
|
||||
Dictionary<string, object> errorMsg = JsonMapper.ToObject<Dictionary<string, object>>(msgJsonData["error"].ToJson());
|
||||
if (errorMsg["code"] != null) { errorDict.Add("code", errorMsg["code"]); }
|
||||
if (errorMsg["reason"] != null) { errorDict.Add("message", errorMsg["reason"]); }
|
||||
FailBiddingADSource((string)msgDict["placement_id"],extraJson, errorDict);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static public void setClientForPlacementID(string placementID, ATSplashAdClient client) {
|
||||
if (clients == null) clients = new Dictionary<string, ATSplashAdClient>();
|
||||
if (clients.ContainsKey(placementID)) clients.Remove(placementID);
|
||||
clients.Add(placementID, client);
|
||||
}
|
||||
|
||||
static public void loadSplashAd(string placementID, string customData) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::loadSplashAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "loadSplashAdWithPlacementID:customDataJSONString:callback:", new object[]{placementID, customData != null ? customData : ""}, true);
|
||||
}
|
||||
|
||||
static public bool hasSplashAdReady(string placementID) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::isSplashAdReady(" + placementID + ")");
|
||||
return ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "splashAdReadyForPlacementID:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public void showSplashAd(string placementID, string mapJson) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::showSplashAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "showSplashAdWithPlacementID:extraJsonString:", new object[]{placementID, mapJson});
|
||||
}
|
||||
|
||||
static public void clearCache(string placementID) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::clearCache()");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "clearCache", null);
|
||||
}
|
||||
|
||||
static public string checkAdStatus(string placementID) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::checkAdStatus(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "checkAdStatus:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public string getValidAdCaches(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::checkAdStatus(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "getValidAdCaches:", new object[] { placementID });
|
||||
}
|
||||
|
||||
static public void entryScenarioWithPlacementID(string placementID, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::entryScenarioWithPlacementID(" + placementID + scenarioID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "entryScenarioWithPlacementID:scenarioID:", new object[]{placementID, scenarioID});
|
||||
}
|
||||
|
||||
//Callbacks
|
||||
static private void OnSplashAdLoaded(string placementID) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdLoaded()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdLoaded(placementID);
|
||||
}
|
||||
|
||||
static private void OnSplashAdLoadFailure(string placementID, Dictionary<string, object> errorDict) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdLoadFailure()");
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdLoadFailure(placementID, (string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static private void OnSplashAdVideoPlayFailure(string placementID, Dictionary<string, object> errorDict) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdVideoPlayFailure()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdVideoPlayFailure(placementID, (string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static private void OnSplashAdVideoPlayStart(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdPlayStart()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdVideoPlayStart(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnSplashAdVideoPlayEnd(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdVideoPlayEnd()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdVideoPlayEnd(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnSplashAdShow(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdShow()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdShow(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnSplashAdFailedToShow(string placementID) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdFailedToShow()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdFailedToShow(placementID);
|
||||
}
|
||||
|
||||
static private void OnSplashAdClick(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdClick()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdClick(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static private void OnSplashAdClose(string placementID, string callbackJson) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::OnSplashAdClose()");
|
||||
if (clients[placementID] != null) clients[placementID].OnSplashAdClose(placementID, callbackJson);
|
||||
}
|
||||
// ad source callback
|
||||
static public void StartLoadingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::StartLoadingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].startLoadingADSource(placementID, callbackJson);
|
||||
}
|
||||
static public void FinishLoadingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::FinishLoadingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].finishLoadingADSource(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void FailToLoadADSource(string placementID,string callbackJson, Dictionary<string, object> errorDict)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::FailToLoadADSource()");
|
||||
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].failToLoadADSource(placementID,callbackJson,(string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
static public void StartBiddingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::StartBiddingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].startBiddingADSource(placementID, callbackJson);
|
||||
}
|
||||
static public void FinishBiddingADSource(string placementID, string callbackJson)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::FinishBiddingADSource()");
|
||||
if (clients[placementID] != null) clients[placementID].finishBiddingADSource(placementID, callbackJson);
|
||||
}
|
||||
|
||||
static public void FailBiddingADSource(string placementID, string callbackJson,Dictionary<string, object> errorDict)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::FailBiddingADSource()");
|
||||
|
||||
Debug.Log("placementID = " + placementID + "errorDict = " + JsonMapper.ToJson(errorDict));
|
||||
if (clients[placementID] != null) clients[placementID].failBiddingADSource(placementID,callbackJson,(string)errorDict["code"], (string)errorDict["message"]);
|
||||
}
|
||||
|
||||
// Auto
|
||||
static public void addAutoLoadAdPlacementID(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::addAutoLoadAdPlacementID(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "addAutoLoadAdPlacementID:callback:", new object[]{placementID}, true);
|
||||
}
|
||||
|
||||
static public void removeAutoLoadAdPlacementID(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::removeAutoLoadAdPlacementID(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "removeAutoLoadAdPlacementID:", new object[]{placementID});
|
||||
}
|
||||
static public bool autoLoadSplashAdReadyForPlacementID(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::autoLoadSplashAdReadyForPlacementID(" + placementID + ")");
|
||||
|
||||
return ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "autoLoadSplashAdReadyForPlacementID:", new object[]{placementID});
|
||||
}
|
||||
static public string getAutoValidAdCaches(string placementID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::getAutoValidAdCaches");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "getAutoValidAdCaches:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public string checkAutoAdStatus(string placementID) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::checkAutoAdStatus(" + placementID + ")");
|
||||
return ATUnityCBridge.GetStringMessageFromC(CMessaageReceiverClass, "checkAutoAdStatus:", new object[]{placementID});
|
||||
}
|
||||
|
||||
static public void setAutoLocalExtra(string placementID, string customData)
|
||||
{
|
||||
|
||||
Debug.Log("Unity: ATSplashAdWrapper::setAutoLocalExtra(" + placementID + customData + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "setAutoLocalExtra:customDataJSONString:", new object[] {placementID, customData != null ? customData : ""});
|
||||
}
|
||||
|
||||
static public void entryAutoAdScenarioWithPlacementID(string placementID, string scenarioID)
|
||||
{
|
||||
Debug.Log("Unity: ATSplashAdWrapper::entryAutoAdScenarioWithPlacementID(" + placementID + scenarioID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "entryAutoAdScenarioWithPlacementID:scenarioID:", new object[]{placementID, scenarioID});
|
||||
}
|
||||
|
||||
static public void showAutoSplashAd(string placementID, string mapJson) {
|
||||
Debug.Log("Unity: ATSplashAdWrapper::showAutoSplashAd(" + placementID + ")");
|
||||
ATUnityCBridge.SendMessageToC(CMessaageReceiverClass, "showAutoSplashAd:extraJsonString:", new object[]{placementID, mapJson});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72f0a51acef9146669a7d7aaa8f899af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -35,6 +35,8 @@ public class ATUnityCBridge {
|
||||
ATBannerAdWrapper.InvokeCallback(jsonData);
|
||||
} else if (wrapperClass.Equals("ATNativeBannerAdWrapper")) {
|
||||
ATNativeBannerAdWrapper.InvokeCallback(jsonData);
|
||||
} else if (wrapperClass.Equals("ATSplashAdWrapper")) {
|
||||
ATSplashAdWrapper.InvokeCallback(jsonData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user