-
Notifications
You must be signed in to change notification settings - Fork 5
1. Setup
Marius Bughiu edited this page Apr 7, 2024
·
2 revisions
In your MauiProgram.cs
call the following method on your app builder:
builder.UseAdMob()
You need to update your app's manifest (Platforms/Android/AndroidManifest.xml
) to include:
- the
AdActivity
activity - the
ACCESS_NETWORK_STATE
andINTERNET
permissions (if they are not present already) - the
APPLICATION_ID
(make sure this is added inside the<application>
element)
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<application ...>
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713" />
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
For more details you can check the official docs: https://developers.google.com/admob/android/quick-start
- Modify your
Platforms/iOS/Info.plist
by adding yourGADApplicationIdentifier
andSKAdNetworkItems
as described here: https://developers.google.com/admob/ios/quick-start - Go to your
Platforms/iOS/AppDelegate.cs
and make a call toGoogle.MobileAds.MobileAds.SharedInstance.Start(completionHandler: null)
. YourAppDelegate
should look similar to this:
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp()
{
var app = MauiProgram.CreateMauiApp();
Google.MobileAds.MobileAds.SharedInstance.Start(completionHandler: null);
return app;
}
}