MarcTron.Admob
1.9.0.6
See the version list below for details.
dotnet add package MarcTron.Admob --version 1.9.0.6
NuGet\Install-Package MarcTron.Admob -Version 1.9.0.6
<PackageReference Include="MarcTron.Admob" Version="1.9.0.6" />
paket add MarcTron.Admob --version 1.9.0.6
#r "nuget: MarcTron.Admob, 1.9.0.6"
// Install MarcTron.Admob as a Cake Addin #addin nuget:?package=MarcTron.Admob&version=1.9.0.6 // Install MarcTron.Admob as a Cake Tool #tool nuget:?package=MarcTron.Admob&version=1.9.0.6
MtAdmob plugin for Xamarin
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, Rewarded Videos and Rewearded Interstitials (from version 1.9)
Please, support my work
If possible, please, support my work with few coffees or even better with a Membership! You can do it here: Buy Me A Coffee Your help allows me to continue to spend time on this project and continue to maintain and update it with new features and to be ready for the new Google SDK 20: Google SDK 20 Migration.
Commercial support
The plugin is free to use and I aim to improve it and fix any bugs in the shortest possible time. Said that, if you need faster support with this plugin or in general with your Xamarin or MAUI project, contact me at hightouchinnovation@gmail.com to discuss it further.
Current Status (Version 1.9.06)
Android | iOS | Windows | Mac | |
---|---|---|---|---|
Banner | ✔️ | ✔️ | ❌ | ❌ |
Interstitial | ✔️ | ✔️ | ❌ | ❌ |
Rewarded | ✔️ | ✔️ | ❌ | ❌ |
Rewarded Interstitial | ✔️ | ❌* | ❌ | ❌ |
*They are implemented but currently they are not working. Probably something in the Admob SDK. I'm investigating it.
Methods
Banner | Interstitial | Rewarded | Rewarded Interstitial |
---|---|---|---|
LoadAd | LoadInterstitial | LoadRewarded | LoadRewardedInterstitial |
ShowInterstitial | ShowRewarded | ShowRewardedInterstitial | |
IsInterstitialLoaded | IsRewardedLoaded | IsRewardedInterstitialLoaded |
Events
Banner | Interstitial | Rewarded | Rewarded Interstitial |
---|---|---|---|
AdsLoaded | OnInterstitialLoaded | OnRewardedLoaded | OnRewardedLoaded |
AdsFailedToLoad | OnInterstitialFailedToLoad | OnRewardedFailedToLoad | OnRewardedFailedToLoad |
AdsImpression | OnInterstitialImpression | OnRewardedImpression | OnRewardedImpression |
AdsClicked | OnInterstitialOpened | OnRewardedOpened | OnRewardedOpened |
AdsOpened | OnInterstitialFailedToShow | OnRewardedFailedToShow | OnRewardedFailedToShow |
AdsClosed | OnInterstitialClosed | OnRewardedClosed | OnRewardedClosed |
AdsSwiped** | OnInterstitialClicked* | OnRewardedClicked* | OnRewardedClicked* |
OnUserEarnedReward | OnUserEarnedReward |
*Only supported on iOS **Only supported on Android
IMPORTANT
To allow a smooth toward MAUI, Version 1.9 contains few breaking changes, several fixes and am improved support for Banner. It's not complicated to update your code and it's worth it.
Android
You need to add your Admob APPLICATION_ID to your AppManifest:
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="YOUR APPLICATION ID" />
If you Target android 12 and the app crashes with the following message: "Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent."
You NEED TO update Xamarin.AndroidX.Work.Runtime to version 2.7.0! This will solve the issue
iOS
You need to add GADApplicationIdentifier to your Info.plist: Edit your info.plist adding these Keys:
<key>GADApplicationIdentifier</key>
<string>YOUR APPLICATION ID</string>
<key>GADIsAdManagerApp</key>
<true/>
- If you don't do this, your iOS app will crash
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();
Now you can add the control to your layout.
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 to 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 this property: AdsId: To add the id of your ads AdSize: To chose the size of your banners (from version 1.9) AutoSize: If true, the plugin will update the heightbanner height according to the ads loaded (from version 1.9)
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
UseRestrictedDataProcessing: For compliance with the CCPA
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.ShowRewarded();
To Load a Rewarded Video you can use this line:
CrossMTAdmob.Current.LoadRewarded("xx-xxx-xxx-xxxxxxxxxxxxxxxxx/xxxxxxxxxx");
REWARD INTERSTITIAL (From Version 1.9)
You can show a Rewarded video with a single line of code:
CrossMTAdmob.Current.ShowRewardInterstitial();
To Load a Rewarded Video you can use this line:
CrossMTAdmob.Current.LoadRewardInterstitial("xx-xxx-xxx-xxxxxxxxxxxxxxxxx/xxxxxxxxxx");
IMPORTANT
Remember to include the MTAdmob library with this code (usually it's added automatically):
using MarcTron.Plugin;
IMPORTANT FOR ANDROID:
Before loading ads, you need to call MobileAds.initialize() on OnCreate:
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
MobileAds.Initialize(ApplicationContext);
Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
Remeber to add this to your AppManifest:
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
IMPORTANT FOR IOS:
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 😃
VIDEO
Get Filthy Rich by Monetizing Your Xamarin.Forms App with AdMob - Gerald Versluis (Youtube)
LINKS
Available on Nuget: https://www.nuget.org/packages/MarcTron.Admob
Tutorial: https://www.xamarinexpert.it/admob-made-easy/
To report any issue: https://github.com/marcojak/MTAdmob/issues
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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | 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. monoandroid12.0 is compatible. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 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 2.0
- Xamarin.Build.Download (>= 0.11.4)
- Xamarin.Forms (>= 5.0.0.2578)
-
MonoAndroid 12.0
- Xamarin.Build.Download (>= 0.11.4)
- Xamarin.Forms (>= 5.0.0.2578)
- Xamarin.GooglePlayServices.Ads.Lite (>= 121.4.0)
-
Xamarin.iOS 1.0
- Xamarin.Build.Download (>= 0.11.4)
- Xamarin.Forms (>= 5.0.0.2578)
- Xamarin.Google.iOS.MobileAds (>= 8.13.0.3)
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 | 351 | 8/8/2024 |
2.3.3 | 187 | 7/9/2024 |
2.3.2 | 161 | 6/24/2024 |
2.3.1 | 452 | 5/3/2024 |
2.3.0 | 481 | 3/21/2024 |
2.2.3 | 255 | 3/8/2024 |
2.2.2 | 152 | 3/8/2024 |
2.2.1 | 290 | 2/24/2024 |
2.2.0 | 363 | 2/9/2024 |
2.1.0 | 395 | 1/25/2024 |
1.9.0.6 | 4,565 | 5/21/2023 |
1.9.0.3 | 6,296 | 12/3/2022 |
1.9.0.2 | 1,098 | 11/19/2022 |
1.8.0 | 3,820 | 7/3/2022 |
1.6.9 | 11,018 | 12/23/2021 |
1.6.8 | 7,421 | 11/23/2021 |
1.6.7 | 1,719 | 10/16/2021 |
1.6.6 | 906 | 10/12/2021 |
1.6.5 | 2,037 | 8/24/2021 |
1.6.4 | 1,025 | 8/22/2021 |
1.6.3 | 1,107 | 8/16/2021 |
1.6.2 | 935 | 8/14/2021 |
1.6.1 | 6,473 | 1/23/2021 |
1.6.0 | 5,468 | 11/7/2020 |
1.5.8 | 3,400 | 9/27/2020 |
1.5.7 | 2,991 | 8/1/2020 |
1.5.6 | 2,893 | 6/7/2020 |
1.5.5 | 2,282 | 5/10/2020 |
1.5.0 | 1,609 | 4/11/2020 |
1.4.5 | 3,005 | 11/19/2019 |
1.4.4 | 1,663 | 10/11/2019 |
1.4.3 | 1,108 | 10/7/2019 |
1.4.2 | 1,172 | 9/7/2019 |
1.4.1 | 1,484 | 8/12/2019 |
1.4.0 | 1,226 | 8/2/2019 |
1.3.0 | 1,381 | 6/1/2019 |
1.2.0 | 1,232 | 4/8/2019 |
1.1.0 | 1,210 | 3/22/2019 |
1.0.0 | 1,241 | 3/5/2019 |
Version 1.9.0.6
Updated ads library in SampleMTAdmob.Android
Removed AdsLeftApplication on Android as not used
Version 1.9.0.5
Updated Xamarin.GooglePlayServices.Ads.Lite to version 121.4.0
Version 1.9.0.3
Fixed some issues with iOS
Version 1.9.0
Updated Xamarin.AndroidX.Work.Runtime to 2.7.0 to allow to target Android 12+
Added Rewarded Interstitials to Android and iOS
Added BannerSize to Banners
Refactor code to make the future transition to MAUI easier
Version 1.8.0
Updated Xamarin.GooglePlayServices.Ads.Lite to 120.3.0.5
Updated Xamarin.Google.iOS.MobileAds to 8.13.0.1
Code updated to support new Ads libraries
Version 1.7.0
Added banner click support for iOS (thanks to alex-relov)
Version 1.6.9
Updated Xamarin.GooglePlayServices.Ads.Lite to 120.3.0.3
Removed MyRewardedVideoAdListener
Enabled OnRewardedVideoAdLoaded On Android
Enabled OnRewardedVideoAdFailedToLoad On Android
Enabled OnRewardedVideoAdClosed On Android
Version 1.6.8
Replaced AdSize.SmartBanner as deprecated (thanks to roswer13)
Improved AdFailedToLoad (thanks to roswer13)
Version 1.6.7
Fixed OnRewardedVideoAdCompleted on Android
Updated Xamarin.GooglePlayServices.Ads.Lite to 120.3.0.1
Version 1.6.6
Fixed OnRewardedVideoAdLoaded on Android
Version 1.6.5
Fixed missing events for rewarded video on Android (Regression)
Version 1.6.4
Fixed issue with ADs request on Android
Replaced string consts for content rating filter
Version 1.6.3
Fixed missing events for rewarded video on Android
Version 1.6.2
Updated GooglePlayServices.Ads.Lite to 120.2.0
Updated Xamarin.AndroidX.Annotation to 1.2.0
Removed Personalized property from MTAdView
Version 1.6.1
Removed support for MonoAndroid81
Updated GooglePlayServices.Ads.Lite to 119.6.0
Version 1.6.0
Updated Xamarin.Google.iOS.MobileAds to 7.66 (Required for iOS 14+)
Updated GooglePlayServices.Ads.Lite to 119.1.0
Version 1.5.8
Added support for Comply with Google Play’s Families Policy (Thanks to Abdul Rahman)
Version 1.5.7
Added IsEnabled to disable the ads (banners, interstitials, rewarded videos) (Default = true)
Added UseRestrictedDataProcessing for CCPA compliance (Default = false)
Version 1.5.6
Fixed possible issue with some MONODROID versions for LoadRewardedVideo
Version 1.5.5
Updated MobileAds to 7.57.0 to avoid Apple rejection because of the reference to UIWebView
Version 1.5.0
Updated packages
Improved code
Add custom data to RewardedAd (thanks to Lordinaire)
Version 1.4.5
Automatically added Google.SignIn 4.4.0 (This version is required to compile your project).
Version 1.4.4
Removed deprecated code on iOS
Fixed issues on iOS (Please update from version 1.4.3 and read the README to init your projects)
Version 1.4.3
Added Consent option to iOS
Updated Xamarin.Google.iOS.MobileAds to 7.47.0
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