marcojak/MauiMTAdmob

Compatibility with Xamarin.Google.UserMessagingPlatform version 3.0.0

Closed this issue · 11 comments

Is there a way to use MauiMTAdmob version 1.5.1 along with Xamarin.Google.UserMessagingPlatform version 3.0.0?

As for now I am using Xamarin.Google.UserMessagingPlatform version 2.2.0.1 along with MauiMTAdmob because of compatibility issues, but for some reason the consent message does not appear. I would like to use UserMessagingPlatform's latest version in order to check if there is an issue with the previous ones or with the code I use.

Are there any AndroidX packages that can ensure compatibility of MauiMTAdmob1.5.1 with Xamarin.Google.UserMessagingPlatform 3.0.0?

I'm currently working on the compatibility for UMP 3.0.
As soon as I manage to do it, I'll publish an update for the plugin.

Meanwhile, what problem are you seeing with the consent and plugin?
You can subscribe to some events to check for consent errors.

Also the consent is available only on the licensed version of the plugin. Can you check that your license key is valid? (You get a log message otherwise).

No direct problem. The problem is that I can't get the Xamarin.Google.UserMessagingPlatform present the consent message.

I would like to use the latest version of UserMessagingPlatform in order to find out if the problem lies with the older version of it.

I managed to overcome the compatibility errors of MauiMTAdmob with Xamarin.Google.UserMessagingPlatform 3.0.0, by installing a bunch of AndroidX NuGet packages, but that solution gives me errors during deployment like the following one:

Type com.google.android.gms.measurement.internal.zzip is defined multiple times

so that's a dead end too.

As for the licensed version, it's not the one I'm using.

Just to confirm that the next version will be compatible with UMP 3.0 (I've solved all the compatibility issues).
I'm working on a few improvements and then I'll publish it.

Said that, I don't think the problem is the version of UMP. Many are using this plugin and they can see the consent form so it might be something related to your implementation.

I used both implementations mentioned on SO: https://stackoverflow.com/questions/68302342/guide-for-xamarin-google-usermessagingplatform

They definitely don't work for me. No consent message appears. Can the issue be that I target Android 34? I don't know. I'm only sure for one thing. As I said no message appears.

Also when using UMP 2.2.0.1 along with MauiMTAdMob 1.4.5 and Xamarin.GooglePlayServices.Ads.Lite 122.3.0.4 no ads loaded. Shouldn't they load anyway, even if the UMP message did not load or is that issue related with the UMP problem?

Yes the should appear even if you don't have the consent.
Of course in Europe you must show the consent as they might ban your account otherwise, but for test it's not a problem.
Check that you are using the test ads ID (there are test ads ID for banners, interstitials and even for the appID).
Add your device id to the list of test devices.
This should allow you to load test ads.

Using the library, load an interstitial, and intercept the success or fail events and it will tell you what happened.

Use the same project to see how the library works, it helps a lot

  1. Well, I have the following code in the .xaml file:
            <controls:MTAdView
                x:Name="testBanner"
                AdsId="ca-app-pub-3940256099942544/9214589741"
                HeightRequest="400"
                WidthRequest="400" />
  1. And here is the code from the constructor of the respective xaml.cs file: testBanner.LoadAd();

  2. I have added the .UseMauiMTAdmob() line in the builder in MauiProgram.cs file.

  3. I have added MobileAds.Initialize(this); in the OnCreate method override in MainActivity.cs

  4. I have downloaded google-services.json and utilize the following code in the .csproj file, because the GoogleServiceJson built action is not listed for the file in its properties' Build Action:

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
	<GoogleServicesJson Include="google-services.json" />
</ItemGroup>
  1. I have put the following code in Android's manifest file, with the appropriate IDs of course:
<manifest>
  <application>
    <activity android:name="com.google.android.gms.ads.AdActivity"
              android:value="AD_UNIT_ID"                              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="APP_ID" />

  </application>
</manifest>
  1. I'm running the app using the emulator. I haven't added it as a test device on the AdMob platform, but that wasn't an issue a while ago when developing projects with Xamrin.Forms, so probably it isn't any issue now. I don't think anything has changed regarding the emulator.

No ads load. Am I missing any steps? If not what is going on?

You are initialising the MobileAds instead of the plugin.
You should initialise the plugin (that from what I see you are missing) and then the plugin will take care of the rest.

Spot on! Substituting MobileAds.Initialize(this); with CrossMauiMTAdmob.Current.Init(this, appId); did the trick!

When the update is out I'll keep you posted about UMP 3.0.0, if I haven't found a solution by then about the "missing" consent message.

Not related to UMP: Calling LoadAd is unnecessary. The XAML code is adequate, so step 2 is not needed, only 1.

Version 1.6.0 should be online in the next couple of minutes.
Closing for now and it supports UMP version 3.0.
If there are issues, please open a new issue.

Just wanted to comment that the issue with the UMP is probably related to the App ID. Using a test App Id resolves the issue.
The original app has an ads restriction with the following reasoning: "Google-served ads on screens with replicated content" which is going to be resolved in the next version.
Since the test App Id makes the UMP to work properly, I guess that the restriction also affects the UMP.

Of course for now you can close this issue, I hope for good.