通过按按钮显示插页式广告效果很好。我已经尝试过OnAppearing,但是它会在页面加载到Android之前运行。无论我做什么,即使有延迟的通话,页面显示仍会覆盖广告。
IAdInterstitial_Droid
using System;
using Android.Gms.Ads;
using Verse.Droid;
using Xamarin.Forms;
[assembly: Dependency(typeof(IAdInterstitial_Droid))]
namespace Verse.Droid
{
public class IAdInterstitial_Droid : IAdInterstitial
{
InterstitialAd interstitialAd;
public IAdInterstitial_Droid()
{
interstitialAd = new InterstitialAd(Android.App.Application.Context);
interstitialAd.AdUnitId = "ca-app-pub-3940256099942544/1033173712"; // Admob test ad
LoadAd();
}
void LoadAd()
{
var requestbuilder = new AdRequest.Builder();
interstitialAd.LoadAd(requestbuilder.Build());
}
public void ShowAd()
{
if (interstitialAd.IsLoaded)
interstitialAd.Show();
LoadAd();
}
}
}
IAdInterstitial.cs
using System;
using System.Collections.Generic;
using System.Text;
namespace Verse
{
interface IAdInterstitial
{
void ShowAd();
}
}
显示广告
IAdInterstitial adInterstitial = DependencyService.Get<IAdInterstitial>();
adInterstitial.ShowAd();
答案 0 :(得分:0)
在开始和关闭项目之后,我终于使用MarcTron.Admob插件代替了最初的实现,从而解决了这个问题。