marcojak / MauiMTAdmob

MIT License
109 stars 18 forks source link

Ads on actual devices dont load #88

Closed dylix closed 1 week ago

dylix commented 1 month ago

[DOTNET] Consent not initialised. You need to initialise it using InitialiseConsent before loading an ad.

works fine on emulators, samsung s22 gets that message.. I have users on other phones reporting the same thing.. wasnt an issue until i upgraded to maui version..

this happens regardless if i call CrossMauiMTAdmob.Current.InitialiseConsent(); or CrossMauiMTAdmob.Current.InitialiseAndShowConsentForm();

xcrackia commented 1 month ago

Same here... Works great in dev mode but once flipped to release (including emulator) no ads will load.

Keeping having to downgrade to 1.4.2 to keep things happy.

DOTNET Consent not initialised. You need to initialise it using InitialiseConsent before loading an ad.

marcojak commented 1 month ago

Hi, yesterday I've released version 1.5.0 that should fix few issues with the consent form. Could you let me know if this works for you?

Also, have you configured your consent in your admob website?

On Fri, 9 Aug 2024, 10:11 Brian M., @.***> wrote:

Same here... Works great in dev mode but once flipped to release (including emulator) no ads will load.

Keeping having to downgrade to 1.4.2 to keep things happy.

DOTNET Consent not initialised. You need to initialise it using InitialiseConsent before loading an ad.

— Reply to this email directly, view it on GitHub https://github.com/marcojak/MauiMTAdmob/issues/88#issuecomment-2277508756, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUIPISO2QB3PWNPXH5SBYLZQSBVJAVCNFSM6AAAAABMDLJOLKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZXGUYDQNZVGY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

xcrackia commented 1 month ago

I should have stated that I was using 1.5.0 this morning and that was the result (no ads in release w/ consent not init error)

I configured the admob consent last week when I upgraded to 1.4.5 which resolved the problem in dev with ads no loading.

But once released I noticed a drop in ad revenue and realized they not showing in release mode.

marcojak commented 1 month ago

Interesting.

I think the linker is removing something related to the consent and without the consent the library doesn't show the ads.

Could you try to disable the linker on your side as a test? I'll do some tests on my side and see if I can preserve everything when in release.

On Fri, 9 Aug 2024, 10:31 Brian M., @.***> wrote:

I should have stated that I was using 1.5.0 this morning and that was the result (no ads in release w/ consent not init error)

I configured the admob consent last week when I upgraded to 1.4.5 which resolved the problem in dev with ads no loading.

But once released I noticed a drop in ad revenue and realized they not showing in release mode.

— Reply to this email directly, view it on GitHub https://github.com/marcojak/MauiMTAdmob/issues/88#issuecomment-2277543438, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUIPIXAUPCSOXKZDAKSCA3ZQSD6RAVCNFSM6AAAAABMDLJOLKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZXGU2DGNBTHA . You are receiving this because you commented.Message ID: @.***>

dylix commented 1 month ago

same here, I tried 1.5.0 and nothing changed on my end.

However, for me, even in debug mode I don't get ads until after ~40-45secs on real devices. Sims still work fine

xcrackia commented 1 month ago

Tested 1.5.0 with linker disabled in release and yielded the result (release = no consent / dev = ads).

Note that I purchased a license key so not sure if that has any play with the issue but figured it's was worth mentioning just incase.

marcojak commented 1 month ago

Just for test, can you try to subscribe to the following event to see if they are called: CrossMauiMTAdmob.Current.OnConsentFormLoadSuccess += Current_OnConsentFormLoadSuccess; CrossMauiMTAdmob.Current.OnConsentFormLoadFailure += Current_OnConsentFormLoadFailure; CrossMauiMTAdmob.Current.OnConsentFormDismissed += Current_OnConsentFormDismissed; CrossMauiMTAdmob.Current.OnConsentInfoUpdateSuccess += Current_OnConsentInfoUpdateSuccess; CrossMauiMTAdmob.Current.OnConsentInfoUpdateFailure += Current_OnConsentInfoUpdateFailure;

xcrackia commented 1 month ago

Wired up the events and testing with Android only. Getting a malformed request (Android).

Note that masked out my app ID but the ID is valid and has been for a long time. Double checked consent management in admob and I have Euro & IDFA configured. Should also note that my app is only US/CA.

Time    Device Name Type    PID Tag Message
08-09 10:42:02.817  pixel_5_-_api_34    Info    7871    DOTNET  OnConsentInfoUpdateFailure: Publisher misconfiguration: Malformed request; the requested app ID is likely malformed, please fix it and try again. Received app ID: `ca-app-pub-xxxxxxxxxxxxx/yyyyyyyy`. 3
08-09 10:42:02.821  pixel_5_-_api_34    Info    7871    DOTNET  OnConsentInfoUpdateFailure
marcojak commented 1 month ago

I'm not sure why you are getting this error. Every website online with that error points to a misconfiguration. In the Init method on Android, there is a parameter for the app id. Are you filling that? Is that the same app id from the manifest? Meanwhile, I'll add something to skip the consent request. As your app is US/CA only, I think it's fine to skip it (and most likely the consent status in US would be "NOT_REQUIRED'. It's just a workaround but at least it would quickly solve the issue and allow the app to receive ads.

marcojak commented 1 month ago

I've just released version 1.5.1 of the plugin.

It adds the property SkipConsent. Set it to true before calling the Init method and it will skip the consent form initialising the plugin. Just add this CrossMauiMTAdmob.Current.SkipConsent = true; before the init

Another question, are you using anything to obscure your code? I'm wondering if in case, that could case some issues in this case.

dylix commented 1 month ago

sweet, thanks @marcojak this fixed my issue I was having with whatever was causing the ~45second delay. Banners and Interstitial load now w/o delay.

xcrackia commented 1 month ago

@marcojak the new switch is perfect, working great and huge thanks for this! Only a matter of time before the US enforces one but until then I can use this. I didn't have the long delays that @dylix had, but can agree that the ads appear to be loading faster.

I did some testing and found the issue that was causing my problems. I found a discrepancy during release where the app ID was swapped out when init CrossMauiMTAdmob and thus it was different than the manifest app ID entry.

My solution was to setup constant value, nix the manifest entry and wire up the meta-data tag in the MainApplication.

MainApplication

[Application] 
[MetaData("com.google.android.gms.ads.APPLICATION_ID", Value = Constants.ADMOB_ANDROID_APP_ID)] 
public class MainApplication : MauiApplication

MainActivity

CrossMauiMTAdmob.Current.Init(this,
     appId: Constants.ADMOB_ANDROID_APP_ID
 );
CrossMauiMTAdmob.Current.SkipConsent = true;