Add advertise to Xamarin with Google AdMob
💣STEP BY STEP ADD ADVERTISE ON XAMARIN APPLICATION
Step 1: Create Google Admob account for your Google Play Application
Step 2: Choose your advertise type
Step 3: Create Keys for your Google Play app
Now Let's go Visual Studio:
Step 4: We need to download MarcTron.Admob Package on your project : [Package Name: MarcTron.Admob]
Step 5:
Setup for Android:
<application>
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 --> This ID is Example
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
</application>
You must write your key in android:value = "" part!
MobileAds.Initialize(ApplicationContext);
Note: Also need this => using Android.Gms.Ads;
Setup for IOS:
In Info.plist you need to add this code in part:
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~3347511713</string>
<key>GADIsADManagerApp</key>
<true/>
Open AppDelegate.cs Script and this code in FinishedLaunching() Method:
MobileAds.SharedInstance.Start(CompletionHandler);
// Create a CompletionHandler Method
private void CompletionHandler(InitializationStatus status)
{
}
Last Step: Open your Xaml page and also in ContentPage Like this:
<ContantPage xmlns:s="clr-namespace:MarcTron.Plugin.Controls;assembly=Plugin.MtAdmob">
Then write in ContantPage this Code and also look at step 3 beacuse we use this keys:
<admob:MTAdView AdsId="ca-app-pub-3940256099942544/6300978111"/>