Hello,
Welcome to our Microsoft Q&A platform!
To display the google Admob ads in Xamarin.Forms, we need to install the required packages for the native platform project: Xamarin.GooglePlayServices.Ads for Android and Xamarin.Firebase.iOS.AdMob for iOS. Then try creating a customView which display the ads and render the ads in native project using custom renderer.
public class AdsView : View
{
//you could add some properies to define the ads view
public AdsView()
{
this.BackgroundColor = Color.Accent;
}
}
Custom renderer class
[assembly: ExportRenderer(typeof(AdsView), typeof(AdsViewRenderer))]
namespace AdMobTestSample.Droid
{
public class AdsViewRenderer : ViewRenderer
{
Context context;
public AdsViewRenderer(Context _context) : base(_context)
{
context = _context;
}
protected override void OnElementChanged(ElementChangedEventArgs<View> e)
{
base.OnElementChanged(e);
...
var adView = new AdView(Context);
adView.AdUnitId = "Your AdMob id";
var requestbuilder = new AdRequest.Builder();
adView.LoadAd(requestbuilder.Build());
SetNativeControl(adView);
}
}
}
For more details, you could search with the keyword as Display Google AdMob Ads In Xamarin Forms to view the related documentation.
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.