[英]Admob native ads click is not working in unity (Android Platform)
I add the native ad in my unity game and ads details are shown properly but my ad click is not working.. I added the box collider manually and detect the click right but still ad is not redirecting to link.我在我的 unity 游戏中添加了原生广告,广告详细信息显示正确,但我的广告点击不起作用。我手动添加了盒子对撞机并检测到正确的点击,但广告仍然没有重定向到链接。
I used test ids right now.我现在使用测试 ID。 If anyone can help me with this issue its great help.
如果有人可以帮助我解决这个问题,那将是很大的帮助。 Thanks In Advance.
提前致谢。
I done many solutions but nothing work for me yet.我做了很多解决方案,但还没有对我有用。 Below are the details of solutions I had try
以下是我尝试过的解决方案的详细信息
1.I disabled the raycast target of every object of native ads 2.Added the box Collider manually to every object 3. I added below line in android manifest file under Activity block of UnityPlayerActivity 1.我禁用了原生广告的每个 object 的光线投射目标 2.手动添加了框碰撞器到每个 object 3.我在 android 清单文件中的 UnityPlayerActivity 的活动块下添加了以下行
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
Here is my code,这是我的代码,
using UnityEngine;
using UnityEngine.UI;
using GoogleMobileAds.Api;
using System;
//Banner ad
public class Admob : MonoBehaviour
{
private BannerView adBanner;
private NativeAd adNative;
private bool nativeLoaded = false;
private string idApp, idBanner, idNative;
[SerializeField] GameObject adNativePanel;
[SerializeField] RawImage adIcon;
[SerializeField] RawImage adChoices;
[SerializeField] Text adHeadline;
[SerializeField] Text adCallToAction;
[SerializeField] Text adAdvertiser;
void Awake ()
{
adNativePanel.SetActive (false); //hide ad panel
}
void Start ()
{
idApp = "ca-app-pub-3940256099942544~3347511713";
idBanner = "ca-app-pub-3940256099942544/6300978111";
idNative = "ca-app-pub-3940256099942544/2247696110";
MobileAds.Initialize (idApp);
RequestBannerAd ();
RequestNativeAd ();
}
void Update ()
{
if (nativeLoaded) {
nativeLoaded = false;
Texture2D iconTexture = this.adNative.GetIconTexture ();
Texture2D iconAdChoices = this.adNative.GetAdChoicesLogoTexture ();
string headline = this.adNative.GetHeadlineText ();
string cta = this.adNative.GetCallToActionText ();
string advertiser = this.adNative.GetAdvertiserText ();
adIcon.texture = iconTexture;
adChoices.texture = iconAdChoices;
adHeadline.text = headline;
adAdvertiser.text = advertiser;
adCallToAction.text = cta;
//register gameobjects
adNative.RegisterIconImageGameObject (adIcon.gameObject);
adNative.RegisterAdChoicesLogoGameObject (adChoices.gameObject);
adNative.RegisterHeadlineTextGameObject (adHeadline.gameObject);
adNative.RegisterCallToActionGameObject (adCallToAction.gameObject);
adNative.RegisterAdvertiserTextGameObject (adAdvertiser.gameObject);
adNativePanel.SetActive (true); //show ad panel
}
}
#region Banner Methods --------------------------------------------------
public void RequestBannerAd ()
{
adBanner = new BannerView (idBanner, AdSize.Banner, AdPosition.Bottom);
AdRequest request = AdRequestBuild ();
adBanner.LoadAd (request);
}
public void DestroyBannerAd ()
{
if (adBanner != null)
adBanner.Destroy ();
}
#endregion
#region Native Ad Mehods ------------------------------------------------
private void RequestNativeAd ()
{
AdLoader adLoader = new AdLoader.Builder (idNative).ForNativeAd ().Build ();
adLoader.OnNativeAdLoaded += this.HandleOnNativeAdLoaded;
adLoader.LoadAd (AdRequestBuild ());
}
//events
private void HandleOnNativeAdLoaded (object sender, NativeAdEventArgs args)
{
this.adNative = args.nativeAd;
nativeLoaded = true;
}
#endregion
//------------------------------------------------------------------------
AdRequest AdRequestBuild ()
{
return new AdRequest.Builder ().Build ();
}
void OnDestroy ()
{
DestroyBannerAd ();
}
}
Did you read the first line on the 'Get Started' page for Native Ads in Unity?您是否阅读了 Unity 原生广告“入门”页面上的第一行? ( https://developers.google.com/admob/unity/native )
( https://developers.google.com/admob/unity/native )
It says:它说:
"Note: Native ads on Unity is in closed beta . To use native ads, contact your account manager." “注意: Unity 上的原生广告处于封闭测试阶段。要使用原生广告,请联系您的客户经理。”
(I was in the same boat as you: I had done everything correctly, but somehow it didn't work. Then I read that note about the closed beta and realized that that is most likely the explanation.) (我和你在同一条船上:我做的一切都正确,但不知何故它不起作用。然后我读了关于内测的注释,意识到这很可能是解释。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.