MarcTron.Admob
1.4.2
See the version list below for details.
dotnet add package MarcTron.Admob --version 1.4.2
NuGet\Install-Package MarcTron.Admob -Version 1.4.2
<PackageReference Include="MarcTron.Admob" Version="1.4.2" />
paket add MarcTron.Admob --version 1.4.2
#r "nuget: MarcTron.Admob, 1.4.2"
// Install MarcTron.Admob as a Cake Addin #addin nuget:?package=MarcTron.Admob&version=1.4.2 // Install MarcTron.Admob as a Cake Tool #tool nuget:?package=MarcTron.Admob&version=1.4.2
MtAdmob Readme
With this Plugin you can add a Google Admob Ads inside your Xamarin Android and iOS Projects with a single line!!! This plugin supports: Banners, Interstitial and Rewarded Videos
Release Notes
Version 1.4.2 Updated GooglePlayServicesAds.Lite 71.1720.1
Version 1.4.1 Fixed issue on iOS where sometimes events weren't called on RewardedVideos
Version 1.4 Fixed issue with multiple events called on RewardedVideos Improved code for Interstitials.
Version 1.3 Fixed crash on iOS with multiple Banner Improved code To avoid compatibilty now the Banner control has been renamed from AdView to MTAdView
Version 1.2 With this version Loading and Showing Interstitials and rewarded videos are 2 separate events. Now the methods are:
- void LoadInterstitial(string adUnit);
- void ShowInterstitial();
- bool IsInterstitialLoaded();
- void LoadRewardedVideo(string adUnit);
- void ShowRewardedVideo();
- bool IsRewardedVideoLoaded();
I've removed the two methods:
- void ShowInterstitial(string adUnit);
- void ShowRewardedVideo(string adUnit);
Now you have to load the Interstitial or Rewarded Video and when you want you can show it. You can see if an interstitial or rewared video are loaded using the new methods
- bool IsInterstitialLoaded();
- bool IsRewardedVideoLoaded();
Thanks to these changes you have now more control over the Ads.
Version 1.1
- Added support for Rewarded Videos
- Added events for Rewarded Videos
- Added events for Interstitials
Version 1.0
- Banner and Insterstitial for Android
- Banner and Insterstitial for iOS
BANNER
To add a Banner on a page you have two options:
XAML
<controls:MTAdView x:Name="myAds"></controls:MTAdView>
remember to add this line in your XAML:
xmlns:controls="clr-namespace:MarcTron.Plugin.Controls;assembly=Plugin.MtAdmob"
CODE
MTAdView ads = new MTAdView();
IMPORTANT
To test the banner during the development google uses two Banner Id, one for Android and the other for iOS. Use them then remember to replace them with your own IDs:
Android: ca-app-pub-3940256099942544/6300978111
iOS: ca-app-pub-3940256099942544/2934735716
If the Banners don't appear in your app, probably it's a size problem. To solve it, add this style you your app.xaml:
<Style TargetType="controls:MTAdView">
<Setter Property="HeightRequest">
<Setter.Value>
<x:OnIdiom Phone="50" Tablet="90"></x:OnIdiom>
</Setter.Value>
</Setter>
</Style>
PROPERTIES
For each AdView if you want, you can set these properties: AdsId: To add the id of your ads
PersonalizedAds: You can set it to False if you want to use generic ads (for GDPR...) (It works only for Android Banners, for the others, you must ask for consent)
For GDPR it's better to rely on a custom consent instead or using the non personalized ads as I cannot guarantee it works. So it's better if you create a custom consent
GLOBAL PROPERTIES
AdsId: To add the id of your ads
PersonalizedAds: You can set it to False if you want to use generic ads (for GDPR...) (It works only for Android Banners, for the others, you must ask for consent) For GDPR it's better to rely on a custom consent instead or using the non personalized ads as I cannot guarantee it works. So it's better if you create a custom consent
TestDevices: You can add here the ID of your test devices
You can use Global Properties in this way: CrossMTAdmob.Current.UserPersonalizedAds = true;
INTERSTITIAL
You can show an interstitial with a single line of code:
CrossMTAdmob.Current.ShowInterstitial();
To Load an interstitial you can use this line:
CrossMTAdmob.Current.LoadInterstitial("xx-xxx-xxx-xxxxxxxxxxxxxxxxx/xxxxxxxxxx");
REWARDED VIDEO
You can show a Rewarded video with a single line of code:
CrossMTAdmob.Current.ShowRewardedVideo();
To Load a Rewarded Video you can use this line:
CrossMTAdmob.Current.LoadRewardedVideo("xx-xxx-xxx-xxxxxxxxxxxxxxxxx/xxxxxxxxxx");
EVENTS FOR BANNERS
Just in case you need, the Banner ads offer 4 events:
AdsClicked When a user clicks on the ads
AdsClosed When the user closes the ads
AdsImpression Called when an impression is recorded for an ad.
AdsOpened When the ads is opened
EVENTS FOR INTERSTITIALS
the Interstitial ads offer 3 events:
OnInterstitialLoaded When it's loaded
OnInterstitialOpened When it's opened
OnInterstitialClosed When it's closed
EVENTS FOR REWARDED VIDEOS
The Rewarded Videos offer 7 events:
OnRewarded When the user gets a reward
OnRewardedVideoAdClosed When the ads is closed
OnRewardedVideoAdFailedToLoad When the ads fails to load
OnRewardedVideoAdLeftApplication When the users leaves the application
OnRewardedVideoAdLoaded When the ads is loaded
OnRewardedVideoAdOpened When the ads is opened
OnRewardedVideoStarted When the ads starts
IMPORTANT
Remember to include the MTAdmob library with this code (usually it's added automatically):
using MarcTron.Plugin;
IMPORTANT FOR ANDROID:
Before loading ads, have your app initialize the Mobile Ads SDK by calling MobileAds.initialize() with your AdMob App ID. This needs to be done only once, ideally at app launch. For example:
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
MobileAds.Initialize(ApplicationContext, "xx-xxx-xxx-xxxxxxxxxxxxxxxx~xxxxxxxxxx");
Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
IMPORTANT FOR IOS:
Before loading ads, have your app initialize the Mobile Ads SDK by calling MobileAds.initialize() with your AdMob App ID. This needs to be done only once, ideally at app launch. For example:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
MobileAds.Configure("xx-xxx-xxx-xxxxxxxxxxxxxxxx~xxxxxxxxxx");
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
**In case the plugin doesn't install automatically the nuget package
Xamarin.Google.iOS.MobileAds
you need to add it manually.**
That's it. Cannot be easier than that 😃
LINKS
Available on Nuget: https://www.nuget.org/packages/MarcTron.Admob
Project website: https://www.xamarinexpert.it/site/Plugin/MTAdmob
Tutorial: https://www.xamarinexpert.it/admob-made-easy/
To report any issue: https://bitbucket.org/marcojak81/mtadmob
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.0 is compatible. netstandard1.1 was computed. netstandard1.2 was computed. netstandard1.3 was computed. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. monoandroid81 is compatible. monoandroid90 is compatible. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Windows Phone | wp8 was computed. wp81 was computed. wpa81 was computed. |
Windows Store | netcore was computed. netcore45 was computed. netcore451 was computed. |
Xamarin.iOS | xamarinios was computed. xamarinios10 is compatible. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 1.0
- NETStandard.Library (>= 1.6.1)
- Xamarin.Forms (>= 3.5.0.169047)
-
.NETStandard 2.0
- Xamarin.Forms (>= 3.5.0.169047)
-
MonoAndroid 8.1
- Xamarin.Forms (>= 3.5.0.169047)
- Xamarin.GooglePlayServices.Ads.Lite (>= 60.1142.1)
-
MonoAndroid 9.0
- Xamarin.Forms (>= 3.5.0.169047)
- Xamarin.GooglePlayServices.Ads.Lite (>= 71.1720.1)
-
Xamarin.iOS 1.0
- Xamarin.Build.Download (>= 0.4.11)
- Xamarin.Forms (>= 3.5.0.169047)
- Xamarin.Google.iOS.MobileAds (>= 7.38.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MarcTron.Admob:
Package | Downloads |
---|---|
ContactManager.Xamarin
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.4.0 | 387 | 8/8/2024 |
2.3.3 | 191 | 7/9/2024 |
2.3.2 | 163 | 6/24/2024 |
2.3.1 | 466 | 5/3/2024 |
2.3.0 | 489 | 3/21/2024 |
2.2.3 | 257 | 3/8/2024 |
2.2.2 | 154 | 3/8/2024 |
2.2.1 | 292 | 2/24/2024 |
2.2.0 | 367 | 2/9/2024 |
2.1.0 | 397 | 1/25/2024 |
1.9.0.6 | 4,569 | 5/21/2023 |
1.9.0.3 | 6,306 | 12/3/2022 |
1.9.0.2 | 1,100 | 11/19/2022 |
1.8.0 | 3,825 | 7/3/2022 |
1.6.9 | 11,034 | 12/23/2021 |
1.6.8 | 7,423 | 11/23/2021 |
1.6.7 | 1,720 | 10/16/2021 |
1.6.6 | 907 | 10/12/2021 |
1.6.5 | 2,039 | 8/24/2021 |
1.6.4 | 1,026 | 8/22/2021 |
1.6.3 | 1,109 | 8/16/2021 |
1.6.2 | 937 | 8/14/2021 |
1.6.1 | 6,486 | 1/23/2021 |
1.6.0 | 5,474 | 11/7/2020 |
1.5.8 | 3,403 | 9/27/2020 |
1.5.7 | 2,992 | 8/1/2020 |
1.5.6 | 2,894 | 6/7/2020 |
1.5.5 | 2,283 | 5/10/2020 |
1.5.0 | 1,610 | 4/11/2020 |
1.4.5 | 3,007 | 11/19/2019 |
1.4.4 | 1,667 | 10/11/2019 |
1.4.3 | 1,109 | 10/7/2019 |
1.4.2 | 1,173 | 9/7/2019 |
1.4.1 | 1,485 | 8/12/2019 |
1.4.0 | 1,227 | 8/2/2019 |
1.3.0 | 1,384 | 6/1/2019 |
1.2.0 | 1,233 | 4/8/2019 |
1.1.0 | 1,212 | 3/22/2019 |
1.0.0 | 1,245 | 3/5/2019 |
Version 1.4.2
Updated GooglePlayServicesAds.Lite 71.1720.1
Version 1.4.1
Fixed issue on iOS where some events weren't called on RewardedVideos in case of no internet
Version 1.4
Fixed issue with multiple events called on RewardedVideos
Improved code for Interstitials.
Version 1.3
Fixed crash on iOS with multiple Banner
To avoid compatibilty now the Banner control has been renamed from AdView to MTAdView
Version 1.2
Now Load and Show are two separate methods to give you more control over your Ads
Version 1.1
Added support for Rewarded Videos
Added events for Rewarded Videos
Added events for Interstitials
Version 1.0
Banner and Insterstitial for Android
Banner and Insterstitial for iOS