-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdMobBannerRenderer.cs
More file actions
31 lines (23 loc) · 854 Bytes
/
Copy pathAdMobBannerRenderer.cs
File metadata and controls
31 lines (23 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using Android.App;
using Android.Runtime;
using Android.Views;
using Android.Gms.Ads;
using Xamarin.Forms.Platform.Android;
using BabbyJotz;
using BabbyJotz.Android;
[assembly: Xamarin.Forms.ExportRenderer(typeof(AdMobBanner), typeof(AdMobBannerRenderer))]
namespace BabbyJotz.Android {
public class AdMobBannerRenderer : ViewRenderer {
const string AdMobId = "ca-app-pub-8697950901186247/5657658019";
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> e) {
base.OnElementChanged(e);
var view = new AdView(base.Context);
view.AdSize = AdSize.Banner;
view.AdUnitId = AdMobId;
var request = new AdRequest.Builder().Build();
view.LoadAd(request);
base.SetNativeControl(view);
}
}
}