EMI-INDO / emi-indo-cordova-plugin-admob

Cordova Plugin Admob Android | IOS
ISC License
12 stars 2 forks source link

consentInformation.canRequestAds() missing in emiAdmobPlugin.java file #25

Open pepe-botellas opened 1 month ago

pepe-botellas commented 1 month ago

First of all thank you so much for your plugin. It is really helpful.

I managed to use it into my Capacitor project, if someone needs help on this just let me know...

According to the steps explained in this video: https://developers.google.com/admob/android/privacy in STEP 4 REQUEST ADS we should call to consentInformation.canRequestAds() before running MobileAds.initialize() method.

Not sure, but as far as I see on emiAdmobPlugin.java file, MobileAds.initialize is runned without canRequestAds(). Is that correct?

This is the code:

      Log.d(TAG, "Google Mobile Ads SDK: " + MobileAds.getVersion());
      MobileAds.initialize(mActivity, initializationStatus -> {
        Map <String, AdapterStatus> statusMap = initializationStatus.getAdapterStatusMap();
        for (String adapterClass: statusMap.keySet()) {
          AdapterStatus status = statusMap.get(adapterClass);
          if (status != null) {
            Log.d(TAG, String.format("Adapter name:%s,Description:%s,Latency:%d", adapterClass, status.getDescription(), status.getLatency()));
          } else {
            callbackContext.error(MobileAds.ERROR_DOMAIN);
          }
        }
        callbackContext.success("Google Mobile Ads SDK: " + MobileAds.getVersion());
        cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.sdkInitialization');");
      });
      return true;

Should not we call to consentInformation.canRequestAds() first?

      Log.d(TAG, "Google Mobile Ads SDK: " + MobileAds.getVersion());
      if (consentInformation.canRequestAds()){
        MobileAds.initialize(mActivity, initializationStatus -> {
          Map <String, AdapterStatus> statusMap = initializationStatus.getAdapterStatusMap();
          for (String adapterClass: statusMap.keySet()) {
            AdapterStatus status = statusMap.get(adapterClass);
            if (status != null) {
              Log.d(TAG, String.format("Adapter name:%s,Description:%s,Latency:%d", adapterClass, status.getDescription(), status.getLatency()));
            } else {
              callbackContext.error(MobileAds.ERROR_DOMAIN);
            }
          }
          callbackContext.success("Google Mobile Ads SDK: " + MobileAds.getVersion());
          cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.sdkInitialization');");
        });
      }
      return true;

Thanks

EMI-INDO commented 1 month ago

@pepe-botellas

I'm working on a new, more complete api with lots of new functionality, including what you've requested.

EMI-INDO commented 1 month ago

@pepe-botellas

https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/tag/%401.4.9