Commit fbe72d25 authored by 王雪伟's avatar 王雪伟

插屏广告加入回调

parent 55f8d2d7
......@@ -829,14 +829,14 @@ public class AdManager
/// <summary>
/// 播放缓存的插屏广告
/// </summary>
public void PlayCacheInterstitialAd(string slotName, string actionName)
public void PlayCacheInterstitialAd(string slotName, string actionName, ZXADInterstitialListener listener)
{
AdEntity entity = ZXADConfig.Instance.GetAdCache(slotName, "");
if (entity != null)
{
entity.actionName = actionName;
ZXADConfig.Instance.RemoveAdCache(slotName, "");
mPlayCacheInterstitialAdPlatform(entity, new Action<bool>((bl) =>
mPlayCacheInterstitialAdPlatform(entity,listener, new Action<bool>((bl) =>
{
if (bl)
{
......@@ -856,22 +856,22 @@ public class AdManager
}
private void mPlayCacheInterstitialAdPlatform(AdEntity entity, Action<bool> callback)
private void mPlayCacheInterstitialAdPlatform(AdEntity entity, ZXADInterstitialListener listener, Action<bool> callback)
{
switch (entity.adPlatform)
{
case ZXADConfig.PLANTFORM_AD_TT:
//穿山甲插屏广告加载
CSJInterstitialUtil.Instance.PlayCacheInterstitialAd(entity, callback);
CSJInterstitialUtil.Instance.PlayCacheInterstitialAd(entity, callback, listener);
break;
case ZXADConfig.PLANTFORM_AD_GDT:
//广点通插屏广告加载
GDTInterstitialAdUtil.Instance.PlayCacheInterstitialAd(entity, callback);
GDTInterstitialAdUtil.Instance.PlayCacheInterstitialAd(entity, callback, listener);
break;
#if UNITY_ANDROID
case ZXADConfig.PLANTFORM_AD_KUS:
//快手插屏广告加载
KsInterstitialAdUtils.Instance.PlayCacheInterstitialAd(entity, callback);
KsInterstitialAdUtils.Instance.PlayCacheInterstitialAd(entity, callback,listener);
break;
#endif
default:
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public interface ZXADInterstitialListener
{
//展示插屏广告
void onInterstitialAdShow();
//插屏广告Error
void onInterstitialError(string errorMsg);
//插屏广告关闭
void onInterstitialClose();
}
fileFormatVersion: 2
guid: df6493c8cebe4674388300fe68e8d28c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -14,8 +14,8 @@ public class ZXADConfig
}
}
public const int ZXAD_VC = 136;
public const string ZXAD_VN = "1.3.6";
public const int ZXAD_VC = 137;
public const string ZXAD_VN = "1.3.7";
public const string ADManagerTAG = "AdManager";
public const string PLANTFORM_AD_TT = "chuanshanjia"; //穿山甲
......
......@@ -66,17 +66,18 @@ public class CSJInterstitialUtil
#else
.SetCodeId(entity.codeId)
.SetExpressViewAcceptedSize(350, 0)
////期望模板广告view的size,单位dp,//高度设置为0,则高度会自适应
////期望模板广告view的size,单位dp,//高度设置为0,则高度会自适应
#endif
.SetSupportDeepLink(true)
.SetAdCount(1)
.SetImageAcceptedSize(1080, 1920)
.Build();
this.AdNative.LoadExpressInterstitialAd(adSlot, new InterstitialAdListener(entity,callback));
this.AdNative.LoadExpressInterstitialAd(adSlot, new InterstitialAdListener(entity, callback));
}
public void PlayCacheInterstitialAd(AdEntity entity,Action<bool> callback)
public void PlayCacheInterstitialAd(AdEntity entity, Action<bool> callback, ZXADInterstitialListener listener)
{
#if UNITY_IOS
if (interstitialAdCacheListIOS.Count > 0)
{
......@@ -87,7 +88,7 @@ public class CSJInterstitialUtil
//{
// y = 100; // 防止Demo里刘海遮挡
//}
mInterstitialAd.SetExpressInteractionListener(new ExpressAdInteractionListener(this, callback, entity, 1));
mInterstitialAd.SetExpressInteractionListener(new ExpressAdInteractionListener(this, listener,callback, entity, 1));
mInterstitialAd.ShowExpressAd(x, y);
}
else
......@@ -100,14 +101,14 @@ public class CSJInterstitialUtil
if (interstitialAdCacheListAndroid.Count > 0)
{
mInterstitialAd = interstitialAdCacheListAndroid.Dequeue();
ExpressAdInteractionListener expressAdInteractionListener = new ExpressAdInteractionListener(this, callback,entity, 1);
ExpressAdInteractionListener expressAdInteractionListener = new ExpressAdInteractionListener(this, listener, callback, entity, 1);
NativeAdManager.Instance().ShowExpressInterstitialAd(GetActivity(), mInterstitialAd.handle, expressAdInteractionListener);
}
else
{
Debug.Log("CSJ 插屏广告没有缓存数据了");
callback(false);
}
#endif
}
......@@ -117,7 +118,7 @@ public class CSJInterstitialUtil
{
private AdEntity entity;
private Action<bool> callback;
public InterstitialAdListener(AdEntity entity,Action<bool> callback)
public InterstitialAdListener(AdEntity entity, Action<bool> callback)
{
this.entity = entity;
this.callback = callback;
......@@ -171,13 +172,15 @@ public class CSJInterstitialUtil
{
private CSJInterstitialUtil example;
private Action<bool> callback;
private ZXADInterstitialListener listener;
private AdEntity entity;
int type;//0:feed 1:banner 2:interstitial
public ExpressAdInteractionListener(CSJInterstitialUtil example,Action<bool> callback,AdEntity entity, int type)
public ExpressAdInteractionListener(CSJInterstitialUtil example, ZXADInterstitialListener listener, Action<bool> callback, AdEntity entity, int type)
{
this.example = example;
this.callback = callback;
this.listener = listener;
this.entity = entity;
this.type = type;
}
......@@ -191,6 +194,7 @@ public class CSJInterstitialUtil
{
EventUtils.onEventShowSuccess(entity);
Debug.Log("express OnAdShow,type:" + type);
listener.onInterstitialAdShow();
}
public void OnAdViewRenderError(ExpressAd ad, int code, string message)
......@@ -198,6 +202,7 @@ public class CSJInterstitialUtil
EventUtils.onEventShowFail(entity);
Debug.Log("express OnAdViewRenderError,type:" + type);
callback(false);
listener.onInterstitialError("code " + code + " message " + message);
}
public void OnAdViewRenderSucc(ExpressAd ad, float width, float height)
......@@ -209,6 +214,7 @@ public class CSJInterstitialUtil
{
EventUtils.onEventAdComplete(entity);
Debug.Log("express OnAdClose,type:" + type);
listener.onInterstitialClose();
}
public void onAdRemoved(ExpressAd ad)
......
......@@ -197,7 +197,25 @@ public class AdDemo : MonoBehaviour
public void OnClickPlayInterAd()
{
AdManager.Instance.PlayCacheInterstitialAd(Interstitial, "test");
AdManager.Instance.PlayCacheInterstitialAd(Interstitial, "test",new InterstitialAdListener());
}
private sealed class InterstitialAdListener : ZXADInterstitialListener
{
public void onInterstitialAdShow()
{
Debug.unityLogger.Log("onInterstitialAdShow");
}
public void onInterstitialClose()
{
Debug.unityLogger.Log("onInterstitialClose");
}
public void onInterstitialError(string errorMsg)
{
Debug.unityLogger.Log("onInterstitialError");
}
}
public void OnClickLoadFullScreeVideoAd()
......
......@@ -39,7 +39,7 @@ public class GDTInterstitialAdUtil
//string posId = Constants.intersititialNoVideoPosId;//不带视频的插屏广告测试Id
UnifiedInterstitialAd ad = new UnifiedInterstitialAd(entity.codeId);
ad.SetListener(new UnifiedInterstitialAdListener(entity,ad, callback));
ad.SetListener(new UnifiedInterstitialAdListener(entity,ad,null, callback));
ad.LoadAd();
}
......@@ -47,12 +47,12 @@ public class GDTInterstitialAdUtil
/// 播放缓存的插屏广告
/// </summary>
/// <param name="entity"></param>
public void PlayCacheInterstitialAd(AdEntity entity,Action<bool> callback)
public void PlayCacheInterstitialAd(AdEntity entity,Action<bool> callback,ZXADInterstitialListener listener)
{
if (interstitialAdCacheList.Count > 0)
{
UnifiedInterstitialAd interAd = interstitialAdCacheList.Dequeue();
interAd.SetListener(new UnifiedInterstitialAdListener(entity,interAd, callback));
interAd.SetListener(new UnifiedInterstitialAdListener(entity,interAd, listener, callback));
interAd.Show();
}
else
......@@ -71,11 +71,13 @@ public class GDTInterstitialAdUtil
{
private AdEntity entity;
private UnifiedInterstitialAd ad;
private ZXADInterstitialListener listener;
private Action<bool> callback;
public UnifiedInterstitialAdListener(AdEntity entity,UnifiedInterstitialAd ad, Action<bool> callback)
public UnifiedInterstitialAdListener(AdEntity entity,UnifiedInterstitialAd ad, ZXADInterstitialListener listener, Action<bool> callback)
{
this.entity = entity;
this.ad = ad;
this.listener = listener;
this.callback = callback;
}
......@@ -112,6 +114,10 @@ public class GDTInterstitialAdUtil
public void OnAdExposured()
{
callback(true);
if (listener != null)
{
listener.onInterstitialAdShow();
}
}
/// <summary>
......@@ -135,7 +141,10 @@ public class GDTInterstitialAdUtil
/// </summary>
public void OnAdClosed()
{
if (listener != null)
{
listener.onInterstitialClose();
}
}
#if UNITY_ANDROID
......@@ -195,6 +204,10 @@ public class GDTInterstitialAdUtil
public void OnVideoError()
{
EventUtils.onEventShowFail(entity);
if (listener != null)
{
listener.onInterstitialError("GDT 插屏播放时出现错误");
}
}
/// <summary>
......
......@@ -208,10 +208,10 @@ public class KsDemo : MonoBehaviour
entity.codeGroup = "A";
entity.slotName = "Tessss";
#if UNITY_ANDROID
KsInterstitialAdUtils.Instance.PlayCacheInterstitialAd(entity, new Action<bool>((cb) => {
//KsInterstitialAdUtils.Instance.PlayCacheInterstitialAd(entity, new Action<bool>((cb) => {
}));
//}));
#endif
}
}
......@@ -41,13 +41,13 @@ public class KsInterstitialAdUtils
/// 播放缓存的插屏广告
/// </summary>
/// <param name="entity"></param>
public void PlayCacheInterstitialAd(AdEntity entity, Action<bool> callback)
public void PlayCacheInterstitialAd(AdEntity entity, Action<bool> callback, ZXADInterstitialListener listener)
{
if (interstitialAdCacheList.Count > 0)
{
Debug.unityLogger.Log("KS 插屏广告没有缓存数据了"+ interstitialAdCacheList.Count);
KsInterstitialAd interAd = interstitialAdCacheList.Dequeue();
interAd.SetPlayListener(new KsInterstitialPlayAdListener(callback, entity));
interAd.SetPlayListener(new KsInterstitialPlayAdListener(callback, listener, entity));
interAd.ShowKsIntetstitialAd();
}
else
......@@ -86,11 +86,13 @@ public class KsInterstitialAdUtils
private sealed class KsInterstitialPlayAdListener : IKsUnityInterstitialPlayListener
{
private Action<bool> callback;
private ZXADInterstitialListener listener;
private AdEntity entity;
public KsInterstitialPlayAdListener(Action<bool> callback, AdEntity entity)
public KsInterstitialPlayAdListener(Action<bool> callback, ZXADInterstitialListener listener, AdEntity entity)
{
this.callback = callback;
this.listener = listener;
this.entity = entity;
}
public void onAdClicked()
......@@ -100,12 +102,13 @@ public class KsInterstitialAdUtils
public void onAdClosed()
{
listener.onInterstitialClose();
}
public void onAdShow()
{
EventUtils.onEventShowSuccess(entity);
listener.onInterstitialAdShow();
}
public void onPageDismiss()
......@@ -127,6 +130,7 @@ public class KsInterstitialAdUtils
{
EventUtils.onEventShowFail(entity);
callback(false);
listener.onInterstitialError("code"+ code+"msg"+msg);
}
public void onVideoPlayStart()
......
......@@ -53,5 +53,20 @@
</intent-filter>
</activity>
<!-- WebView -->
<provider
android:name="com.bytedance.sdk.openadsdk.TTFileProvider"
android:authorities="${applicationId}.TTFileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<provider
android:name="com.bytedance.sdk.openadsdk.multipro.TTMultiProvider"
android:authorities="${applicationId}.TTMultiProvider"
android:exported="false" />
</application>
</manifest>
......@@ -24,14 +24,16 @@ public class CallingNativeMethods
}
return activity;
}
//判断微信是否安装
#if UNITY_IOS
//判断微信是否安装
[DllImport("__Internal")]
private static extern bool _isWechatInstalled();
[DllImport("__Internal")]
private static extern void _WechatLogin(string appid, string state, string universalLink);
[DllImport("__Internal")]
private static extern void ShowIOSWebView(string urlStr, string titleStr);
#endif
/// <summary>
/// 注册初始化微信登录
......
......@@ -371,19 +371,30 @@ public class UnityPhoneUtils {
}
public String getDeviceId(Context context) {
return getMd5Value(getAndroidID(context) + getImei(context));
}
public String getMd5Value(String sSecret) {
try {
MessageDigest bmd5 = MessageDigest.getInstance("MD5");
bmd5.update(sSecret.getBytes());
int i=0;
StringBuffer buf = new StringBuffer();
byte[] b = bmd5.digest();
for (int j=0;j<b.length;j++){
i = Integer.parseInt(b[j]+"");
if (i < 0)
i += 256;
if (i < 16)
buf.append("0");
buf.append(Integer.toHexString(i));
}
return buf.toString();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return "";
}
return "";
}
public String getImei(Context context) {
......
This diff is collapsed.
......@@ -41,6 +41,12 @@ PlayerSettings:
height: 1
m_SplashScreenLogos: []
m_VirtualRealitySplashScreen: {fileID: 0}
m_ShowUnitySplashAds: 0
m_AdsAndroidGameId:
m_AdsIosGameId:
m_ShowSplashAdsSlogan: 0
m_SloganImage: {fileID: 0}
m_SloganHeight: 150
m_HolographicTrackingLossScreen: {fileID: 0}
defaultScreenWidth: 1920
defaultScreenHeight: 1080
......@@ -118,13 +124,14 @@ PlayerSettings:
vulkanNumSwapchainBuffers: 3
vulkanEnableSetSRGBWrite: 0
vulkanEnableLateAcquireNextImage: 0
useSecurityBuild: 0
m_SupportedAspectRatios:
4:3: 1
5:4: 1
16:10: 1
16:9: 1
Others: 1
bundleVersion: 1.0.7
bundleVersion: 1.0.0
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
......@@ -168,7 +175,7 @@ PlayerSettings:
androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1
applicationIdentifier:
Android: com.ym.wdlc
Android: com.ym.chxxx
Lumin: com.DefaultCompany.com.unity.template.mobile2D
Standalone: com.DefaultCompany.com.unity.template.mobile2D
iPhone: com.ym.iosawpdd
......@@ -177,7 +184,7 @@ PlayerSettings:
Standalone: 0
iPhone: 0
tvOS: 0
AndroidBundleVersionCode: 8
AndroidBundleVersionCode: 1
AndroidMinSdkVersion: 21
AndroidTargetSdkVersion: 0
AndroidPreferredInstallLocation: 1
......@@ -263,7 +270,7 @@ PlayerSettings:
AndroidEnableTango: 0
androidEnableBanner: 1
androidUseLowAccuracyLocation: 0
androidUseCustomKeystore: 0
androidUseCustomKeystore: 1
m_AndroidBanners:
- width: 320
height: 180
......@@ -366,6 +373,7 @@ PlayerSettings:
m_Kind: 2
m_SubKind:
m_BuildTargetBatching: []
m_BuildTargetEncrypting: []
m_BuildTargetGraphicsJobs:
- m_BuildTarget: MacStandaloneSupport
m_GraphicsJobs: 0
......@@ -647,7 +655,7 @@ PlayerSettings:
scriptingDefineSymbols: {}
platformArchitecture: {}
scriptingBackend:
Android: 0
Android: 1
il2cppCompilerConfiguration: {}
managedStrippingLevel: {}
incrementalIl2cppBuild: {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment