修复admob获取不到价格/比价不展示广告问题

This commit is contained in:
juncong lee 2025-09-25 13:55:15 +08:00
parent 1a4641f788
commit 80c7f251c6
14 changed files with 84 additions and 164 deletions

View File

@ -503,7 +503,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -317, y: 0}
m_AnchoredPosition: {x: -77, y: 295}
m_SizeDelta: {x: 160, y: 81.78}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &231270964
@ -670,7 +670,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Native1Show
m_Text: "\u9690\u85CF\u6298\u53E0"
--- !u!222 &317264882
CanvasRenderer:
m_ObjectHideFlags: 0
@ -974,7 +974,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: "\u63D2\u5C4F"
m_Text: "\u6298\u53E0banner"
--- !u!222 &522908631
CanvasRenderer:
m_ObjectHideFlags: 0
@ -1231,7 +1231,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -108, y: -123.51}
m_AnchoredPosition: {x: 121, y: 297}
m_SizeDelta: {x: 160, y: 81.78}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &988501506
@ -1989,7 +1989,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -317, y: -238}
m_AnchoredPosition: {x: -78, y: 168}
m_SizeDelta: {x: 160, y: 81.78}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1238066088
@ -2390,7 +2390,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1439137377
RectTransform:
m_ObjectHideFlags: 0
@ -2484,7 +2484,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -108, y: 0}
m_AnchoredPosition: {x: 118, y: 174}
m_SizeDelta: {x: 160, y: 81.78}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1560301800
@ -2863,7 +2863,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: "\u6FC0\u52B1"
m_Text: "\u666E\u901Abanner"
--- !u!222 &1715967760
CanvasRenderer:
m_ObjectHideFlags: 0
@ -2942,7 +2942,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Native1Hide
m_Text: "\u9690\u85CF\u666E\u901A"
--- !u!222 &1839779890
CanvasRenderer:
m_ObjectHideFlags: 0
@ -3047,7 +3047,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1979832641
RectTransform:
m_ObjectHideFlags: 0

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using GoogleMobileAds.Api;
namespace WZ
@ -56,6 +57,7 @@ namespace WZ
}
LoggerUtils.Debug("Admob Interstitial ad loaded with response : " + ad.GetResponseInfo().ToString());
LoggerUtils.Debug("Admob Interstitial ad loaded with Getsrevenue:"+AdmobUtils.GetInterstitialAdEcpm(ad));
_interstitialAds[adUnitId] = ad;
_adRevenueCache[adUnitId] = AdmobUtils.GetInterstitialAdEcpm(ad);
AdsKeyEvents.Instance.LogAdFPUEvents(AdsType.Interstitial);
@ -160,23 +162,11 @@ namespace WZ
// 获取价格最高的广告位ID
public string GetHighestPayingAdUnit()
{
string highestPayingAdUnit = null;
double highestRevenue = -1;
foreach (var kvp in _adRevenueCache)
{
var adUnitId = kvp.Key;
var revenue = kvp.Value;
// 确保广告确实已加载并且价格更高
if (IsAdAvailable(adUnitId) && revenue > highestRevenue)
{
highestRevenue = revenue;
highestPayingAdUnit = adUnitId;
}
}
return highestPayingAdUnit;
return _adRevenueCache
.Where(kvp => IsAdAvailable(kvp.Key))
.OrderByDescending(kvp => kvp.Value)
.Select(kvp => kvp.Key)
.FirstOrDefault();
}
// 获取价格最高的广告收益信息
@ -188,7 +178,7 @@ namespace WZ
{
return revenue;
}
return 0;
return -1;
}
// 清理资源

View File

@ -324,24 +324,11 @@ namespace WZ
// 获取价格最高的广告位ID
public string GetHighestPayingAdUnit()
{
string highestPayingAdUnit = null;
double highestRevenue = -1;
LoggerUtils.Debug($"[Admob] Native ad GetHighestPayingAdUnit {_adRevenueCache.Count}");
foreach (var kvp in _adRevenueCache)
{
var adUnitId = kvp.Key;
var revenue = kvp.Value;
// 确保广告确实已加载并且价格更高
if (IsAdAvailable(adUnitId) && revenue > highestRevenue)
{
highestRevenue = revenue;
highestPayingAdUnit = adUnitId;
}
}
return highestPayingAdUnit;
return _adRevenueCache
.Where(kvp => IsAdAvailable(kvp.Key))
.OrderByDescending(kvp => kvp.Value)
.Select(kvp => kvp.Key)
.FirstOrDefault();
}
// 获取价格最高的广告收益信息
@ -354,7 +341,7 @@ namespace WZ
return revenue;
}
return 0;
return -1;
}
// 获取广告收益信息

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using GoogleMobileAds.Api;
@ -51,7 +52,7 @@ namespace WZ
return;
}
LoggerUtils.Debug("[Admob] rewarded ad loaded with response : " + ad.GetResponseInfo().ToString()+"revenue:"+AdmobUtils.GetRewardedAdEcpm(ad));
LoggerUtils.Debug("[Admob] rewarded ad loaded with response : " + ad.GetResponseInfo().ToString());
LoggerUtils.Debug("[Admob] rewarded ad revenue : " +AdmobUtils.GetRewardedAdEcpm(ad));
if (!AdmobAdsManager.Instance.FindAdsID(AdsType.Rewarded, adUnitId))
@ -158,23 +159,11 @@ namespace WZ
// 获取价格最高的广告位ID
public string GetHighestPayingAdUnit()
{
string highestPayingAdUnit = null;
double highestRevenue = -1;
foreach (var kvp in _adRevenueCache)
{
var adUnitId = kvp.Key;
var revenue = kvp.Value;
// 确保广告确实已加载并且价格更高
if (IsAdAvailable(adUnitId) && revenue > highestRevenue)
{
highestRevenue = revenue;
highestPayingAdUnit = adUnitId;
}
}
return highestPayingAdUnit;
return _adRevenueCache
.Where(kvp => IsAdAvailable(kvp.Key))
.OrderByDescending(kvp => kvp.Value)
.Select(kvp => kvp.Key)
.FirstOrDefault();
}
// 获取价格最高的广告收益信息

View File

@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using GoogleMobileAds.Api;
using UnityEngine;
@ -52,7 +53,7 @@ namespace WZ
return;
}
LoggerUtils.Debug("[Admob] appopen ad loaded with response : " + ad.GetResponseInfo().ToString()+" revenue:"+AdmobUtils.GetAppOpenAdEcpm(ad));
LoggerUtils.Debug("[Admob] appopen ad loaded with response : " + ad.GetResponseInfo().ToString());
LoggerUtils.Debug("[Admob] appopen ad loaded with revenue : " + AdmobUtils.GetAppOpenAdEcpm(ad));
_appOpenAds[adUnitId] = ad;
_adRevenueCache[adUnitId] = AdmobUtils.GetAppOpenAdEcpm(ad);
@ -149,22 +150,11 @@ namespace WZ
// 获取价格最高的广告位ID
public string GetHighestPayingAdUnit()
{
string highestPayingAdUnit = null;
double highestRevenue = 0;
foreach (var kvp in _adRevenueCache)
{
var adUnitId = kvp.Key;
var revenue = kvp.Value;
// 确保广告确实已加载并且价格更高
if (IsAdAvailable(adUnitId))
{
highestRevenue = revenue;
highestPayingAdUnit = adUnitId;
}
}
return highestPayingAdUnit;
return _adRevenueCache
.Where(kvp => IsAdAvailable(kvp.Key))
.OrderByDescending(kvp => kvp.Value)
.Select(kvp => kvp.Key)
.FirstOrDefault();
}
// 获取价格最高的广告收益信息
@ -176,7 +166,7 @@ namespace WZ
{
return revenue;
}
return 0;
return -1;
}
// 清理资源

View File

@ -2,6 +2,7 @@ using System.Collections.Generic;
using GoogleMobileAds.Api;
using System;
using UnityEngine;
using System.Linq;
namespace WZ
{
@ -43,7 +44,8 @@ namespace WZ
{
_retryCounters[adUnitId] = 0;
_adRevenueCache[adUnitId] = AdmobUtils.GetBannerEcpm(bannerAds);
LoggerUtils.Debug($"[Admob] banner -[Load]: {adUnitId} successfully");
LoggerUtils.Debug($"[Admob] banner -[Load]: {adUnitId} successfully, ecpm = {AdmobUtils.GetBannerEcpm(bannerAds)}");
AdsActionEvents.TrackAdLoaded(AdmobAdsManager.Instance.Platfrom,
bannerAds?.GetResponseInfo()?.GetLoadedAdapterResponseInfo()?.AdSourceName ?? "",
adUnitId,
@ -130,7 +132,6 @@ namespace WZ
{
return;
}
if (_bannerAds.TryGetValue(adUnitId, out var ad))
{
ad.SetPosition(bannerAlignType == BannerAlignType.CenterBottom ? AdPosition.Bottom : AdPosition.Top);
@ -163,23 +164,8 @@ namespace WZ
// 获取价格最高的广告位ID
public string GetHighestPayingAdUnit()
{
string highestPayingAdUnit = null;
double highestRevenue = -1;
foreach (var kvp in _adRevenueCache)
{
var adUnitId = kvp.Key;
var revenue = kvp.Value;
// 确保广告确实已加载并且价格更高
if (revenue > highestRevenue)
{
highestRevenue = revenue;
highestPayingAdUnit = adUnitId;
}
}
return highestPayingAdUnit;
if (_adRevenueCache.Count == 0) return null;
return _adRevenueCache.OrderByDescending(kvp => kvp.Value).First().Key;
}
// 获取价格最高的广告收益信息

View File

@ -2,6 +2,7 @@ using System.Collections.Generic;
using GoogleMobileAds.Api;
using System;
using UnityEngine;
using System.Linq;
namespace WZ
{
@ -43,7 +44,7 @@ namespace WZ
{
_retryCounters[adUnitId] = 0;
_adRevenueCache[adUnitId] = AdmobUtils.GetBannerEcpm(bannerAds);
LoggerUtils.Debug($"[Admob] banner collapsible -[Load]: {adUnitId} successfully iscollapsible: {bannerAds.IsCollapsible()}");
LoggerUtils.Debug($"[Admob] banner collapsible -[Load]: {adUnitId} successfully iscollapsible: {bannerAds.IsCollapsible()},ecpm: {AdmobUtils.GetBannerEcpm(bannerAds)}");
AdsActionEvents.TrackAdLoaded(AdmobAdsManager.Instance.Platfrom,
bannerAds?.GetResponseInfo()?.GetLoadedAdapterResponseInfo()?.AdSourceName ?? "",
@ -169,23 +170,8 @@ namespace WZ
// 获取价格最高的广告位ID
public string GetHighestPayingAdUnit()
{
string highestPayingAdUnit = null;
double highestRevenue = -1;
foreach (var kvp in _adRevenueCache)
{
var adUnitId = kvp.Key;
var revenue = kvp.Value;
// 确保广告确实已加载并且价格更高
if (revenue > highestRevenue)
{
highestRevenue = revenue;
highestPayingAdUnit = adUnitId;
}
}
return highestPayingAdUnit;
if (_adRevenueCache.Count == 0) return null;
return _adRevenueCache.OrderByDescending(kvp => kvp.Value).First().Key;
}
// 获取价格最高的广告收益信息

View File

@ -200,7 +200,7 @@ namespace WZ
{
if (_stack is EmptyStack)
{
return -0.1;
return 0.0000001;
}
try
@ -213,7 +213,7 @@ namespace WZ
catch (Exception e)
{
LoggerUtils.Error("[AdmobTools] e : " + e.Message + "\t cShapeFieldName : " + cShapeFieldName);
return -0.2;
return 0.0000001;
}
@ -234,7 +234,7 @@ namespace WZ
_stack = new EmptyStack();
return -1.0;
return 0.0000001;
}
/// <summary>

View File

@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using BigoAds.Scripts.Api;
using UnityEngine;
@ -161,23 +162,11 @@ namespace WZ
// 获取价格最高的广告位ID
public string GetHighestPayingAdUnit()
{
string highestPayingAdUnit = null;
double highestRevenue = 0;
foreach (var kvp in _adRevenueCache)
{
var adUnitId = kvp.Key;
var revenue = kvp.Value;
// 确保广告确实已加载并且价格更高
if (IsAdAvailable(adUnitId) && revenue > highestRevenue)
{
highestRevenue = revenue;
highestPayingAdUnit = adUnitId;
}
}
return highestPayingAdUnit;
return _adRevenueCache
.Where(kvp => IsAdAvailable(kvp.Key))
.OrderByDescending(kvp => kvp.Value)
.Select(kvp => kvp.Key)
.FirstOrDefault();
}
// 获取价格最高的广告收益信息
@ -189,7 +178,7 @@ namespace WZ
{
return revenue;
}
return 0;
return -1;
}
// 清理资源

View File

@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using BigoAds.Scripts.Api;
using UnityEngine;
@ -169,23 +170,11 @@ namespace WZ
// 获取价格最高的广告位ID
public string GetHighestPayingAdUnit()
{
string highestPayingAdUnit = null;
double highestRevenue = 0;
foreach (var kvp in _adRevenueCache)
{
var adUnitId = kvp.Key;
var revenue = kvp.Value;
// 确保广告确实已加载并且价格更高
if (IsAdAvailable(adUnitId) && revenue > highestRevenue)
{
highestRevenue = revenue;
highestPayingAdUnit = adUnitId;
}
}
return highestPayingAdUnit;
return _adRevenueCache
.Where(kvp => IsAdAvailable(kvp.Key))
.OrderByDescending(kvp => kvp.Value)
.Select(kvp => kvp.Key)
.FirstOrDefault();
}
// 获取价格最高的广告收益信息
@ -197,7 +186,7 @@ namespace WZ
{
return revenue;
}
return 0;
return -1;
}
// 清理资源

View File

@ -159,7 +159,6 @@ namespace WZ
highestPayingAdUnit = adUnitId;
}
}
return highestPayingAdUnit;
}

View File

@ -21,7 +21,7 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
public static string GetSDKVersion()
{
return "1.0.4.2";
return "1.0.4.3";
}
protected override void Initialized()
{

View File

@ -23,7 +23,7 @@ namespace WZ
public static void Info(object message, Object context = null)
{
if (!!_enabled) return;
if (!_enabled) return;
Log($"[INFO][WZSDK] {message}", context);
}
@ -35,7 +35,7 @@ namespace WZ
public static void Error(object message, Object context = null)
{
if (!!_enabled) return;
if (!_enabled) return;
Log($"[ERROR][WZSDK] {message}", context);
}

View File

@ -1,3 +1,18 @@
# Version 1.0.4.3 2025.9.25
## Bugs
- None
## Known issues
- None
## Changelog
- 修复admob广告获取不到收益问题
- 修复只有admob广告准备好的情况下且获取不到比价展示topon问题
# Version 1.0.4.2 2025.9.24
## Bugs