emi-indo-cordova-plugin-admob 0.0.9 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- package emi.indo.cordova.plugin.admob;import android.os.Bundle;import android.util.Log;import android.view.View;import android.view.ViewGroup;import android.widget.RelativeLayout;import androidx.annotation.NonNull;import com.google.ads.mediation.admob.AdMobAdapter;import com.google.android.gms.ads.AdError;import com.google.android.gms.ads.AdListener;import com.google.android.gms.ads.AdRequest;import com.google.android.gms.ads.AdSize;import com.google.android.gms.ads.AdView;import com.google.android.gms.ads.FullScreenContentCallback;import com.google.android.gms.ads.LoadAdError;import com.google.android.gms.ads.MobileAds;import com.google.android.gms.ads.RequestConfiguration;import com.google.android.gms.ads.ResponseInfo;import com.google.android.gms.ads.VersionInfo;import com.google.android.gms.ads.appopen.AppOpenAd;import com.google.android.gms.ads.initialization.AdapterStatus;import com.google.android.gms.ads.interstitial.InterstitialAd;import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;import com.google.android.gms.ads.rewarded.RewardedAd;import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback;import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd;import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAdLoadCallback;import com.google.android.ump.ConsentForm;import com.google.android.ump.ConsentInformation;import com.google.android.ump.ConsentRequestParameters;import com.google.android.ump.UserMessagingPlatform;import org.apache.cordova.CallbackContext;import org.apache.cordova.CordovaInterface;import org.apache.cordova.CordovaPlugin;import org.apache.cordova.CordovaWebView;import org.json.JSONArray;import org.json.JSONException;import java.util.Map;import java.util.Objects;public class emiAdmobPlugin extends CordovaPlugin{private static final String TAG="emiAdmobPlugin";private InterstitialAd mInterstitialAd;private RewardedAd rewardedAd;private RewardedInterstitialAd rewardedInterstitialAd;private CordovaWebView cWebView;private AppOpenAd appOpenAd=null;private boolean isAppOpenAdShow=false;private boolean isbannerShow=true;static boolean isinterstitialload=false;static boolean isrewardedInterstitialload=false;static boolean isrewardedload=false;private ConsentInformation consentInformation;private ConsentForm consentForm;private RelativeLayout bannerViewLayout;private AdView bannerView;public void initialize(CordovaInterface cordova,CordovaWebView webView){super.initialize(cordova,webView);cWebView=webView;}public boolean execute(String action,JSONArray args,final CallbackContext callbackContext)throws JSONException{switch(action){case "initialize":VersionInfo mobileAds=MobileAds.getVersion();MobileAds.initialize(cordova.getActivity(),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()));}}callbackContext.success(mobileAds.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.SdkInitializationComplete');");});return true;case "targeting":cordova.getActivity().runOnUiThread(()->{final boolean TagForChildDirectedTreatment=args.optBoolean(0);final boolean TagForUnderAgeOfConsent=args.optBoolean(1);final String MaxAdContentRating=args.optString(2);if(TagForChildDirectedTreatment){RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE).build();MobileAds.setRequestConfiguration(requestConfiguration);}else{RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE).build();MobileAds.setRequestConfiguration(requestConfiguration);}if(TagForUnderAgeOfConsent){RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE).build();MobileAds.setRequestConfiguration(requestConfiguration);}else{RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE).build();MobileAds.setRequestConfiguration(requestConfiguration);}if(Objects.equals(MaxAdContentRating,"G")){RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_G).build();MobileAds.setRequestConfiguration(requestConfiguration);}else if(Objects.equals(MaxAdContentRating,"MA")){RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_MA).build();MobileAds.setRequestConfiguration(requestConfiguration);}else if(Objects.equals(MaxAdContentRating,"PG")){RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_PG).build();MobileAds.setRequestConfiguration(requestConfiguration);}else if(Objects.equals(MaxAdContentRating,"T")){RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_T).build();MobileAds.setRequestConfiguration(requestConfiguration);}else{RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED).build();MobileAds.setRequestConfiguration(requestConfiguration);}});return true;case "loadAppOpenAd":cordova.getActivity().runOnUiThread(()->{final String appOpenAdUnitId=args.optString(0);final String npa=args.optString(1);final boolean responseInfo=args.optBoolean(2);Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",npa);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();AppOpenAd.load(cordova.getContext(),appOpenAdUnitId,adRequest,new AppOpenAd.AppOpenAdLoadCallback(){@Override public void onAdLoaded(@NonNull AppOpenAd ad){appOpenAd=ad;isAppOpenAdShow=true;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.open.loaded');");if(responseInfo){ResponseInfo responseInfo=appOpenAd.getResponseInfo();callbackContext.success(responseInfo.toString());}}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){isAppOpenAdShow=false;callbackContext.error(loadAdError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.open.failed.loaded');");}});});return true;case "showAppOpenAd":if(isAppOpenAdShow){cordova.getActivity().runOnUiThread(()-> appOpenAd.show(cordova.getActivity()));}else{callbackContext.error("The App Open Ad wasn't ready yet");}return true;case "loadInterstitialAd":cordova.getActivity().runOnUiThread(()->{final String interstitialAdAdUnitId=args.optString(0);final String npa=args.optString(1);final boolean responseInfo=args.optBoolean(2);Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",npa);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();InterstitialAd.load(cordova.getActivity(),interstitialAdAdUnitId,adRequest,new InterstitialAdLoadCallback(){@Override public void onAdLoaded(@NonNull InterstitialAd interstitialAd){isinterstitialload=true;mInterstitialAd=interstitialAd;Log.i(TAG,"onAdLoaded");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdLoaded');");if(responseInfo){ResponseInfo responseInfo=interstitialAd.getResponseInfo();callbackContext.success(responseInfo.toString());}}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){Log.d(TAG,loadAdError.toString());mInterstitialAd=null;isinterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdFailedToLoad');");callbackContext.error(loadAdError.toString());}});});return true;case "showInterstitialAd":if(isinterstitialload){cordova.getActivity().runOnUiThread(()-> mInterstitialAd.show(cordova.getActivity()));}else{callbackContext.error("The Interstitial ad wasn't ready yet");}return true;case "loadRewardedAd":cordova.getActivity().runOnUiThread(()->{final String rewardedAdAdUnitId=args.optString(0);final String npa=args.optString(1);final boolean responseInfo=args.optBoolean(2);Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",npa);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();RewardedAd.load(cordova.getActivity(),rewardedAdAdUnitId,adRequest,new RewardedAdLoadCallback(){public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){Log.d(TAG,loadAdError.toString());rewardedAd=null;isrewardedload=false;Log.d(TAG,"The rewarded ad wasn't ready yet.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.RewardedAdFailedToLoad');");callbackContext.error(loadAdError.toString());}@Override public void onAdLoaded(@NonNull RewardedAd ad){rewardedAd=ad;isrewardedload=true;Log.d(TAG,"Ad was loaded.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.RewardedAdLoaded');");if(responseInfo){ResponseInfo responseInfo=ad.getResponseInfo();callbackContext.success(responseInfo.toString());}}});});return true;case "showRewardedAd":cordova.getActivity().runOnUiThread(()->{if(isrewardedload){rewardedAd.show(cordova.getActivity(),rewardItem ->{Log.d(TAG,"The user earned the reward.");int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.rewarded');");callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});}else{callbackContext.error("The rewarded ad wasn't ready yet");}});return true;case "loadRewardedInterstitialAd":cordova.getActivity().runOnUiThread(()->{final String rewardedInterstitialAdUnitId=args.optString(0);final String npa=args.optString(1);final boolean responseInfo=args.optBoolean(2);Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",npa);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();RewardedInterstitialAd.load(cordova.getActivity(),rewardedInterstitialAdUnitId,adRequest,new RewardedInterstitialAdLoadCallback(){@Override public void onAdLoaded(@NonNull RewardedInterstitialAd ad){Log.d(TAG,"Ad was loaded.");rewardedInterstitialAd=ad;isrewardedInterstitialload=true;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.RewardedInterstitialAdLoaded');");if(responseInfo){ResponseInfo responseInfo=ad.getResponseInfo();callbackContext.success(responseInfo.toString());}}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){Log.d(TAG,loadAdError.toString());rewardedInterstitialAd=null;isrewardedInterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.RewardedInterstitialAdFailedToLoad');");callbackContext.error(loadAdError.toString());}});});return true;case "showRewardedInterstitialAd":cordova.getActivity().runOnUiThread(()->{if(isrewardedInterstitialload){rewardedInterstitialAd.show(cordova.getActivity(),rewardItem ->{Log.d(TAG,"The user earned the reward.");int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitial.rewarded');");callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});}else{Log.d(TAG,"The rewarded ad wasn't ready yet.");callbackContext.error("The rewarded ad wasn't ready yet");}});return true;case "showBannerAd":cordova.getActivity().runOnUiThread(()->{final String bannerAdUnitId=args.optString(0);final String npa=args.optString(1);final String position=args.optString(2);final String size=args.optString(3);final int adaptiveWidth=args.optInt(4);final boolean responseInfo=args.optBoolean(5);if(isbannerShow){if(bannerViewLayout==null){bannerViewLayout=new RelativeLayout(cordova.getActivity());RelativeLayout.LayoutParams params=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT);bannerViewLayout.setLayoutParams(params);try{((ViewGroup)(((View)Objects.requireNonNull(webView.getClass().getMethod("getView").invoke(webView))).getParent())).addView(bannerViewLayout,params);}catch(Exception e){((ViewGroup)webView).addView(bannerViewLayout,params);}}bannerView=new AdView(cordova.getActivity());if(Objects.equals(size,"BANNER")){bannerView.setAdSize(AdSize.BANNER);}else if(Objects.equals(size,"LARGE_BANNER")){bannerView.setAdSize(AdSize.LARGE_BANNER);}else if(Objects.equals(size,"MEDIUM_RECTANGLE")){bannerView.setAdSize(AdSize.MEDIUM_RECTANGLE);}else if(Objects.equals(size,"FULL_BANNER")){bannerView.setAdSize(AdSize.FULL_BANNER);}else if(Objects.equals(size,"LEADERBOARD")){bannerView.setAdSize(AdSize.LEADERBOARD);}else if(Objects.equals(size,"FLUID")){bannerView.setAdSize(AdSize.FLUID);}else if(Objects.equals(size,"Anchored_adaptive")){bannerView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(cordova.getActivity(),adaptiveWidth));}else if(Objects.equals(size,"Inline_adaptive")){bannerView.setAdSize(AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(cordova.getActivity(),adaptiveWidth));}else{bannerView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(cordova.getActivity(),AdSize.FULL_WIDTH));}bannerView.setAdUnitId(bannerAdUnitId);Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",npa);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();bannerView.loadAd(adRequest);isbannerShow=false;RelativeLayout.LayoutParams bannerParams=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);switch(position){case "top-right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);break;case "top-center":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);break;case "left":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "center":bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "bottom-center":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);break;case "bottom-right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);break;default:bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);break;}bannerView.setLayoutParams(bannerParams);bannerViewLayout.addView(bannerView);}bannerView.setAdListener(new AdListener(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdClicked');");}@Override public void onAdClosed(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdClosed');");}@Override public void onAdFailedToLoad(@NonNull LoadAdError adError){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdFailedToLoad');");callbackContext.error(adError.toString());}@Override public void onAdImpression(){isbannerShow=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdImpression');");}@Override public void onAdLoaded(){isbannerShow=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdLoaded');");if(responseInfo){try{ResponseInfo responseInfo=bannerView.getResponseInfo();assert responseInfo!=null;callbackContext.success(responseInfo.toString());}catch(NullPointerException e){e.printStackTrace();}}}@Override public void onAdOpened(){isbannerShow=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdOpened');");}});});return true;case "removeBannerAd":cordova.getActivity().runOnUiThread(()->{if(bannerView==null)return;RelativeLayout bannerViewLayout=(RelativeLayout)bannerView.getParent();if(bannerViewLayout!=null){bannerViewLayout.removeView(bannerView);bannerView.destroy();bannerView=null;isbannerShow=true;}});return true;case "getConsentRequest":final boolean setTagForUnderAgeOfConsent=args.optBoolean(0);cordova.getActivity().runOnUiThread(()->{ConsentRequestParameters params=new ConsentRequestParameters .Builder().setTagForUnderAgeOfConsent(setTagForUnderAgeOfConsent).build();consentInformation=UserMessagingPlatform.getConsentInformation(cordova.getActivity());consentInformation.requestConsentInfoUpdate(cordova.getActivity(),params,()->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onConsentInfoUpdateSuccess');");if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.NOT_REQUIRED){callbackContext.success(ConsentInformation.ConsentStatus.NOT_REQUIRED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentStatus.NOT_REQUIRED');");}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.OBTAINED){callbackContext.success(ConsentInformation.ConsentStatus.OBTAINED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentStatus.OBTAINED');");}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.REQUIRED){callbackContext.success(ConsentInformation.ConsentStatus.REQUIRED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentStatus.REQUIRED');");if(consentInformation.isConsentFormAvailable()){UserMessagingPlatform.loadConsentForm(cordova.getContext(),consentForm -> consentForm.show(cordova.getActivity(),formError ->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ShowError');");callbackContext.error(String.valueOf(formError));}),formError -> callbackContext.error(formError.getMessage()));cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.loadConsentFormError');");}else{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentFormNotAvailable');");}}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.UNKNOWN){callbackContext.success(ConsentInformation.ConsentStatus.UNKNOWN);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentStatus.UNKNOWN');");}},formError ->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onConsentInfoUpdateFailure');");callbackContext.error(formError.getMessage());});});return true;case "consentReset":cordova.getActivity().runOnUiThread(()-> consentInformation.reset());return true;}appOpenAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdDismissedFullScreenContent(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.open.dismissed');");appOpenAd=null;}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.open.failed.show');");callbackContext.error(adError.toString());appOpenAd=null;}@Override public void onAdShowedFullScreenContent(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.open.show');");}});mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){Log.d(TAG,"Ad was clicked.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdClicked');");}@Override public void onAdDismissedFullScreenContent(){Log.d(TAG,"Ad dismissed fullscreen content.");mInterstitialAd=null;isinterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdDismissedFullScreenContent');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){Log.e(TAG,"Ad failed to show fullscreen content.");mInterstitialAd=null;isinterstitialload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdFailedToShowFullScreenContent');");}@Override public void onAdImpression(){Log.d(TAG,"Ad recorded an impression.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdImpression');");}@Override public void onAdShowedFullScreenContent(){Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdShowedFullScreenContent');");}});rewardedAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){Log.d(TAG,"Ad was clicked.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdClicked');");}@Override public void onAdDismissedFullScreenContent(){Log.d(TAG,"Ad dismissed fullscreen content.");rewardedAd=null;isrewardedload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdDismissedFullScreenContent');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){Log.e(TAG,"Ad failed to show fullscreen content.");rewardedAd=null;isrewardedload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdFailedToShowFullScreenContent');");}@Override public void onAdImpression(){Log.d(TAG,"Ad recorded an impression.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdImpression');");}@Override public void onAdShowedFullScreenContent(){Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdShowedFullScreenContent');");}});rewardedInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){Log.d(TAG,"Ad was clicked.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdClicked');");}@Override public void onAdDismissedFullScreenContent(){Log.d(TAG,"Ad dismissed fullscreen content.");rewardedInterstitialAd=null;isrewardedInterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdDismissedFullScreenContent');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){Log.e(TAG,"Ad failed to show fullscreen content.");rewardedInterstitialAd=null;isrewardedInterstitialload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdFailedToShowFullScreenContent');");}@Override public void onAdImpression(){Log.d(TAG,"Ad recorded an impression.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdImpression');");}@Override public void onAdShowedFullScreenContent(){Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdShowedFullScreenContent');");}});return false;}@Override public void onDestroy(){if(bannerView!=null){bannerView.destroy();bannerView=null;}if(bannerViewLayout!=null){ViewGroup parentView=(ViewGroup)bannerViewLayout.getParent();if(parentView!=null){parentView.removeView(bannerViewLayout);}bannerViewLayout=null;}super.onDestroy();}}
1
+ package emi.indo.cordova.plugin.admob;import android.os.Bundle;import android.util.Log;import android.view.View;import android.view.ViewGroup;import android.widget.RelativeLayout;import androidx.annotation.NonNull;import com.google.ads.mediation.admob.AdMobAdapter;import com.google.android.gms.ads.AdError;import com.google.android.gms.ads.AdListener;import com.google.android.gms.ads.AdRequest;import com.google.android.gms.ads.AdSize;import com.google.android.gms.ads.AdValue;import com.google.android.gms.ads.AdView;import com.google.android.gms.ads.FullScreenContentCallback;import com.google.android.gms.ads.LoadAdError;import com.google.android.gms.ads.MobileAds;import com.google.android.gms.ads.OnPaidEventListener;import com.google.android.gms.ads.RequestConfiguration;import com.google.android.gms.ads.ResponseInfo;import com.google.android.gms.ads.appopen.AppOpenAd;import com.google.android.gms.ads.initialization.AdapterStatus;import com.google.android.gms.ads.interstitial.InterstitialAd;import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;import com.google.android.gms.ads.rewarded.RewardedAd;import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback;import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd;import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAdLoadCallback;import com.google.android.ump.ConsentForm;import com.google.android.ump.ConsentInformation;import com.google.android.ump.ConsentRequestParameters;import com.google.android.ump.UserMessagingPlatform;import org.apache.cordova.CallbackContext;import org.apache.cordova.CordovaInterface;import org.apache.cordova.CordovaPlugin;import org.apache.cordova.CordovaWebView;import org.json.JSONArray;import org.json.JSONException;import org.json.JSONObject;import java.util.Map;import java.util.Objects;public class emiAdmobPlugin extends CordovaPlugin{private static final String TAG="emiAdmobPlugin";private CallbackContext PUBLIC_CALLBACKS=null;private InterstitialAd mInterstitialAd;private RewardedAd rewardedAd;private RewardedInterstitialAd rewardedInterstitialAd;private CordovaWebView cWebView;private AppOpenAd appOpenAd=null;private boolean isAppOpenAdShow=false;private boolean isbannerShow=true;static boolean isinterstitialload=false;static boolean isrewardedInterstitialload=false;static boolean isrewardedload=false;static boolean isBannerLoad=false;private int isAdSkip=0;Boolean ResponseInfo=false;String Npa;int SetTagForChildDirectedTreatment;int SetTagForUnderAgeOfConsent;String SetMaxAdContentRating;String appOpenAdUnitId;String bannerAdUnitId;String interstitialAdUnitId;String rewardedInterstitialAdUnitId;String rewardedAdUnitId;boolean SetAppMuted;float SetAppVolume;boolean EnableSameAppKey;private ConsentInformation consentInformation;private ConsentForm consentForm;private RelativeLayout bannerViewLayout;private AdView bannerView;public void initialize(CordovaInterface cordova,CordovaWebView webView){super.initialize(cordova,webView);cWebView=webView;}public boolean execute(String action,JSONArray args,final CallbackContext callbackContext)throws JSONException{PUBLIC_CALLBACKS=callbackContext;switch(action){case "initialize":Log.d(TAG,"Google Mobile Ads SDK: "+MobileAds.getVersion());MobileAds.initialize(cordova.getActivity(),initializationStatus ->{Map<String,AdapterStatus> statusMap=initializationStatus.getAdapterStatusMap();for(String adapterClass:statusMap.keySet()){AdapterStatus status=statusMap.get(adapterClass);if(status!=null){_globalSettings();_Targeting();Log.d(TAG,String.format("Adapter name:%s,Description:%s,Latency:%d",adapterClass,status.getDescription(),status.getLatency()));callbackContext.success(" Google Mobile Ads SDK: "+MobileAds.getVersion());}else{callbackContext.error(MobileAds.ERROR_DOMAIN);}}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.sdkInitialization');");});return true;case "targeting":cordova.getActivity().runOnUiThread(()->{final int TagForChildDirectedTreatment=args.optInt(0);final int TagForUnderAgeOfConsent=args.optInt(1);final String MaxAdContentRating=args.optString(2);try{this.SetTagForChildDirectedTreatment=TagForChildDirectedTreatment;this.SetTagForUnderAgeOfConsent=TagForUnderAgeOfConsent;this.SetMaxAdContentRating=MaxAdContentRating;}catch(Exception e){callbackContext.error(e.toString());}});return true;case "globalSettings":cordova.getActivity().runOnUiThread(()->{final boolean setAppMuted=args.optBoolean(0);final float setAppVolume=(float)args.optDouble(1);final boolean enableSameAppKey=args.optBoolean(2);try{this.SetAppMuted=setAppMuted;this.SetAppVolume=setAppVolume;this.EnableSameAppKey=enableSameAppKey;}catch(Exception e){callbackContext.error(e.toString());}});return true;case "loadAppOpenAd":cordova.getActivity().runOnUiThread(()->{final String AdUnitId=args.optString(0);final String npa=args.optString(1);final boolean responseInfo=args.optBoolean(2);try{this.appOpenAdUnitId=AdUnitId;Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putInt("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();AppOpenAd.load(cordova.getContext(),this.appOpenAdUnitId,adRequest,new AppOpenAd.AppOpenAdLoadCallback(){@Override public void onAdLoaded(@NonNull AppOpenAd ad){appOpenAd=ad;isAppOpenAdShow=true;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.loaded');");if(responseInfo){ResponseInfo responseInfo=appOpenAd.getResponseInfo();callbackContext.success(responseInfo.toString()+ '\n'+'\n'+bundleExtra);}appOpenAd.setOnPaidEventListener(adValue ->{long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=appOpenAd.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);callbackContext.success(result);}catch(JSONException e){callbackContext.error(e.getMessage());}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.revenue');");});}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){isAppOpenAdShow=false;callbackContext.error(loadAdError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.loaded');");}});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "showAppOpenAd":if(isAppOpenAdShow){_appOpenAdLoadCallback(callbackContext);cordova.getActivity().runOnUiThread(()-> appOpenAd.show(cordova.getActivity()));}else{callbackContext.error("The App Open Ad wasn't ready yet");}return true;case "loadInterstitialAd":cordova.getActivity().runOnUiThread(()->{final String AdUnitId=args.optString(0);final String npa=args.optString(1);final boolean responseInfo=args.optBoolean(2);try{this.interstitialAdUnitId=AdUnitId;Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putInt("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();InterstitialAd.load(cordova.getActivity(),this.interstitialAdUnitId,adRequest,new InterstitialAdLoadCallback(){@Override public void onAdLoaded(@NonNull InterstitialAd interstitialAd){isinterstitialload=true;mInterstitialAd=interstitialAd;Log.i(TAG,"onAdLoaded");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.loaded');");if(responseInfo){ResponseInfo responseInfo=interstitialAd.getResponseInfo();callbackContext.success(responseInfo.toString()+ '\n'+'\n'+bundleExtra);}mInterstitialAd.setOnPaidEventListener(adValue ->{long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=mInterstitialAd.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);callbackContext.success(result);}catch(JSONException e){callbackContext.error(e.getMessage());}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.revenue');");});}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){mInterstitialAd=null;isinterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.failed.load');");callbackContext.error(loadAdError.toString());}});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "showInterstitialAd":if(isinterstitialload){_interstitialAdLoadCallback(callbackContext);cordova.getActivity().runOnUiThread(()-> mInterstitialAd.show(cordova.getActivity()));}else{callbackContext.error("The Interstitial ad wasn't ready yet");}return true;case "loadRewardedAd":cordova.getActivity().runOnUiThread(()->{final String AdUnitId=args.optString(0);final String npa=args.optString(1);final boolean responseInfo=args.optBoolean(2);try{this.rewardedAdUnitId=AdUnitId;Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putInt("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();RewardedAd.load(cordova.getActivity(),this.rewardedAdUnitId,adRequest,new RewardedAdLoadCallback(){public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){rewardedAd=null;isrewardedload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.failed.load');");callbackContext.error(loadAdError.toString());}@Override public void onAdLoaded(@NonNull RewardedAd ad){rewardedAd=ad;isrewardedload=true;isAdSkip=0;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.loaded');");if(responseInfo){ResponseInfo responseInfo=ad.getResponseInfo();callbackContext.success(responseInfo.toString()+ '\n'+'\n'+bundleExtra);}rewardedAd.setOnPaidEventListener(adValue ->{long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=rewardedAd.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);callbackContext.success(result);}catch(JSONException e){callbackContext.error(e.getMessage());}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.revenue');");});}});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "showRewardedAd":cordova.getActivity().runOnUiThread(()->{if(isrewardedload){isAdSkip=1;_rewardedAdLoadCallback(callbackContext);rewardedAd.show(cordova.getActivity(),rewardItem ->{isAdSkip=2;int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.reward.userEarnedReward');");callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});}else{callbackContext.error("The rewarded ad wasn't ready yet");}});return true;case "loadRewardedInterstitialAd":cordova.getActivity().runOnUiThread(()->{final String AdUnitId=args.optString(0);final String npa=args.optString(1);final boolean responseInfo=args.optBoolean(2);try{this.rewardedInterstitialAdUnitId=AdUnitId;Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putInt("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();RewardedInterstitialAd.load(cordova.getActivity(),this.rewardedInterstitialAdUnitId,adRequest,new RewardedInterstitialAdLoadCallback(){@Override public void onAdLoaded(@NonNull RewardedInterstitialAd ad){rewardedInterstitialAd=ad;isrewardedInterstitialload=true;isAdSkip=0;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.loaded');");if(responseInfo){ResponseInfo responseInfo=ad.getResponseInfo();callbackContext.success(responseInfo.toString()+ '\n'+'\n'+bundleExtra);}rewardedInterstitialAd.setOnPaidEventListener(adValue ->{long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=rewardedInterstitialAd.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);callbackContext.success(result);}catch(JSONException e){callbackContext.error(e.getMessage());}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.revenue');");});}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){rewardedInterstitialAd=null;isrewardedInterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.failed.load');");callbackContext.error(loadAdError.toString());}});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "showRewardedInterstitialAd":cordova.getActivity().runOnUiThread(()->{if(isrewardedInterstitialload){isAdSkip=1;_rewardedInterstitialAdLoadCallback(callbackContext);rewardedInterstitialAd.show(cordova.getActivity(),rewardItem ->{isAdSkip=2;int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.userEarnedReward');");callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});}else{callbackContext.error("The rewarded ad wasn't ready yet");}});return true;case "showBannerAd":cordova.getActivity().runOnUiThread(()->{if(isBannerLoad){bannerViewLayout.addView(bannerView);isBannerLoad=false;}});return true;case "loadBannerAd":cordova.getActivity().runOnUiThread(()->{final String AdUnitId=args.optString(0);final String npa=args.optString(1);final String position=args.optString(2);final String size=args.optString(3);final int adaptiveWidth=args.optInt(4);final boolean responseInfo=args.optBoolean(5);try{this.bannerAdUnitId=AdUnitId;this.ResponseInfo=responseInfo;this.Npa=npa;if(isbannerShow){if(bannerViewLayout==null){bannerViewLayout=new RelativeLayout(cordova.getActivity());RelativeLayout.LayoutParams params=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT);bannerViewLayout.setLayoutParams(params);try{((ViewGroup)(((View)Objects.requireNonNull(webView.getClass().getMethod("getView").invoke(webView))).getParent())).addView(bannerViewLayout,params);}catch(Exception e){((ViewGroup)webView).addView(bannerViewLayout,params);}}bannerView=new AdView(cordova.getActivity());if(Objects.equals(size,"BANNER")){bannerView.setAdSize(AdSize.BANNER);}else if(Objects.equals(size,"LARGE_BANNER")){bannerView.setAdSize(AdSize.LARGE_BANNER);}else if(Objects.equals(size,"MEDIUM_RECTANGLE")){bannerView.setAdSize(AdSize.MEDIUM_RECTANGLE);}else if(Objects.equals(size,"FULL_BANNER")){bannerView.setAdSize(AdSize.FULL_BANNER);}else if(Objects.equals(size,"LEADERBOARD")){bannerView.setAdSize(AdSize.LEADERBOARD);}else if(Objects.equals(size,"FLUID")){bannerView.setAdSize(AdSize.FLUID);}else if(Objects.equals(size,"Anchored_adaptive")){bannerView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(cordova.getActivity(),adaptiveWidth));}else if(Objects.equals(size,"Inline_adaptive")){bannerView.setAdSize(AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(cordova.getActivity(),adaptiveWidth));}else{bannerView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(cordova.getActivity(),AdSize.FULL_WIDTH));}bannerView.setAdUnitId(this.bannerAdUnitId);Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putInt("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();bannerView.loadAd(adRequest);bannerView.setAdListener(bannerAdListener);isbannerShow=false;RelativeLayout.LayoutParams bannerParams=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);switch(position){case "top-right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);break;case "top-center":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);break;case "left":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "center":bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "bottom-center":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);break;case "bottom-right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);break;default:bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);break;}bannerView.setLayoutParams(bannerParams);}}catch(Exception e){callbackContext.error(e.toString());}});return true;case "removeBannerAd":cordova.getActivity().runOnUiThread(()->{if(bannerView==null)return;RelativeLayout bannerViewLayout=(RelativeLayout)bannerView.getParent();if(bannerViewLayout!=null){bannerViewLayout.removeView(bannerView);bannerView.destroy();bannerView=null;isbannerShow=true;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.remove');");}});return true;case "getConsentRequest":cordova.getActivity().runOnUiThread(()->{try{ConsentRequestParameters params=new ConsentRequestParameters .Builder().build();consentInformation=UserMessagingPlatform.getConsentInformation(cordova.getActivity());consentInformation.requestConsentInfoUpdate(cordova.getActivity(),params,()->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update');");if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.NOT_REQUIRED){callbackContext.success(ConsentInformation.ConsentStatus.NOT_REQUIRED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.not_required');");}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.OBTAINED){callbackContext.success(ConsentInformation.ConsentStatus.OBTAINED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.obtained');");}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.REQUIRED){callbackContext.success(ConsentInformation.ConsentStatus.REQUIRED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.required');");if(consentInformation.isConsentFormAvailable()){UserMessagingPlatform.loadConsentForm(cordova.getContext(),consentForm -> consentForm.show(cordova.getActivity(),formError ->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show');");callbackContext.error(String.valueOf(formError));}),formError -> callbackContext.error(formError.getMessage()));cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.load.from');");}else{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.form.not.available');");}}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.UNKNOWN){callbackContext.success(ConsentInformation.ConsentStatus.UNKNOWN);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.unknown');");}},formError ->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update.failed');");callbackContext.error(formError.getMessage());});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "consentReset":cordova.getActivity().runOnUiThread(()-> consentInformation.reset());return true;}return false;}private final AdListener bannerAdListener=new AdListener(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.click');");}@Override public void onAdClosed(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.close');");}@Override public void onAdFailedToLoad(@NonNull LoadAdError adError){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load');");PUBLIC_CALLBACKS.error(adError.toString());}@Override public void onAdImpression(){isbannerShow=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.impression');");}@Override public void onAdLoaded(){isbannerShow=false;isBannerLoad=true;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.load');");bannerView.setOnPaidEventListener(bannerPaidAdListener);if(ResponseInfo){Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",Npa);bundleExtra.putInt("is_designed_for_families",SetTagForChildDirectedTreatment);bundleExtra.putInt("under_age_of_consent",SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",SetMaxAdContentRating);try{ResponseInfo responseInfo=bannerView.getResponseInfo();assert responseInfo!=null;PUBLIC_CALLBACKS.success(responseInfo.toString()+ '\n'+'\n'+bundleExtra);}catch(NullPointerException e){e.printStackTrace();}}}@Override public void onAdOpened(){isbannerShow=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.open');");}};private final OnPaidEventListener bannerPaidAdListener=new OnPaidEventListener(){@Override public void onPaidEvent(@NonNull AdValue adValue){long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=bannerView.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);PUBLIC_CALLBACKS.success(result);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.revenue');");}catch(JSONException e){PUBLIC_CALLBACKS.error(e.getMessage());}}};private void _appOpenAdLoadCallback(CallbackContext callbackContext){appOpenAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdDismissedFullScreenContent(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.dismissed');");appOpenAd=null;}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.show');");callbackContext.error(adError.toString());appOpenAd=null;}@Override public void onAdShowedFullScreenContent(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.show');");}});}private void _interstitialAdLoadCallback(CallbackContext callbackContext){mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.click');");}@Override public void onAdDismissedFullScreenContent(){mInterstitialAd=null;isinterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.dismissed');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){mInterstitialAd=null;isinterstitialload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.failed.show');");}@Override public void onAdImpression(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.impression');");}@Override public void onAdShowedFullScreenContent(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.show');");}});}private void _rewardedAdLoadCallback(CallbackContext callbackContext){rewardedAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.click');");}@Override public void onAdDismissedFullScreenContent(){if(isAdSkip!=2){rewardedAd=null;isrewardedload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.ad.skip');");}rewardedAd=null;isrewardedload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.dismissed');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){rewardedAd=null;isrewardedload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.failed.show');");}@Override public void onAdImpression(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.impression');");}@Override public void onAdShowedFullScreenContent(){isAdSkip=1;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.show');");}});}private void _rewardedInterstitialAdLoadCallback(CallbackContext callbackContext){rewardedInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.click');");}@Override public void onAdDismissedFullScreenContent(){if(isAdSkip!=2){rewardedInterstitialAd=null;isrewardedInterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.ad.skip');");}rewardedInterstitialAd=null;isrewardedInterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.dismissed');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){rewardedInterstitialAd=null;isrewardedInterstitialload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.failed.show');");}@Override public void onAdImpression(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.impression');");}@Override public void onAdShowedFullScreenContent(){isAdSkip=1;Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.showed');");}});}public void _globalSettings(){MobileAds.setAppMuted(this.SetAppMuted);MobileAds.setAppVolume(this.SetAppVolume);MobileAds.enableSameAppKey(this.EnableSameAppKey);}public void _Targeting(){RequestConfiguration.Builder requestConfiguration=MobileAds.getRequestConfiguration().toBuilder();if(SetTagForChildDirectedTreatment==-1){requestConfiguration.setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED);}else if(SetTagForChildDirectedTreatment==0){requestConfiguration.setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE);}else if(SetTagForChildDirectedTreatment==1){requestConfiguration.setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE);}else{requestConfiguration.setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED);}if(SetTagForUnderAgeOfConsent==-1){requestConfiguration.setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED);}else if(SetTagForUnderAgeOfConsent==0){requestConfiguration.setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE);}else if(SetTagForUnderAgeOfConsent==1){requestConfiguration.setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE);}else{requestConfiguration.setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED);}if(Objects.equals(SetMaxAdContentRating,"")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED);}else if(Objects.equals(SetMaxAdContentRating,"T")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_T);}else if(Objects.equals(SetMaxAdContentRating,"PG")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_PG);}else if(Objects.equals(SetMaxAdContentRating,"MA")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_MA);}else if(Objects.equals(SetMaxAdContentRating,"G")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_G);}else{requestConfiguration.setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED);}MobileAds.setRequestConfiguration(requestConfiguration.build());}@Override public void onDestroy(){if(bannerView!=null){bannerView.destroy();bannerView=null;}if(bannerViewLayout!=null){ViewGroup parentView=(ViewGroup)bannerViewLayout.getParent();if(parentView!=null){parentView.removeView(bannerViewLayout);}bannerViewLayout=null;}super.onDestroy();}}
@@ -1,19 +1,23 @@
1
1
  var exec = require('cordova/exec');
2
2
 
3
- exports.initialize = function (arg0, success, error) {
4
- exec(success, error, 'emiAdmobPlugin', 'initialize', [arg0]);
3
+ exports.initialize = function (success, error) {
4
+ exec(success, error, 'emiAdmobPlugin', 'initialize', []);
5
5
  };
6
6
 
7
7
  exports.loadAppOpenAd = function (arg0, arg1, arg2, success, error) {
8
8
  exec(success, error, 'emiAdmobPlugin', 'loadAppOpenAd', [arg0, arg1, arg2]);
9
9
  };
10
10
 
11
- exports.showAppOpenAd = function (arg0, success, error) {
12
- exec(success, error, 'emiAdmobPlugin', 'showAppOpenAd', [arg0]);
11
+ exports.showAppOpenAd = function (success, error) {
12
+ exec(success, error, 'emiAdmobPlugin', 'showAppOpenAd', []);
13
13
  };
14
14
 
15
- exports.showBannerAd = function (arg0, arg1, arg2, arg3, arg4, arg5, success, error) {
16
- exec(success, error, 'emiAdmobPlugin', 'showBannerAd', [arg0, arg1, arg2, arg3, arg4, arg5]);
15
+ exports.loadBannerAd = function (arg0, arg1, arg2, arg3, arg4, arg5, success, error) {
16
+ exec(success, error, 'emiAdmobPlugin', 'loadBannerAd', [arg0, arg1, arg2, arg3, arg4, arg5]);
17
+ };
18
+
19
+ exports.showBannerAd = function (success, error) {
20
+ exec(success, error, 'emiAdmobPlugin', 'showBannerAd', []);
17
21
  };
18
22
 
19
23
  exports.removeBannerAd = function (arg0, success, error) {
@@ -24,34 +28,38 @@ exports.loadInterstitialAd = function (arg0, arg1, arg2, success, error) {
24
28
  exec(success, error, 'emiAdmobPlugin', 'loadInterstitialAd', [arg0, arg1, arg2]);
25
29
  };
26
30
 
27
- exports.showInterstitialAd = function (arg0, success, error) {
28
- exec(success, error, 'emiAdmobPlugin', 'showInterstitialAd', [arg0]);
31
+ exports.showInterstitialAd = function (success, error) {
32
+ exec(success, error, 'emiAdmobPlugin', 'showInterstitialAd', []);
29
33
  };
30
34
 
31
35
  exports.loadRewardedAd = function (arg0, arg1, arg2, success, error) {
32
36
  exec(success, error, 'emiAdmobPlugin', 'loadRewardedAd', [arg0, arg1, arg2]);
33
37
  };
34
38
 
35
- exports.showRewardedAd = function (arg0, success, error) {
36
- exec(success, error, 'emiAdmobPlugin', 'showRewardedAd', [arg0]);
39
+ exports.showRewardedAd = function (success, error) {
40
+ exec(success, error, 'emiAdmobPlugin', 'showRewardedAd', []);
37
41
  };
38
42
 
39
43
  exports.loadRewardedInterstitialAd = function (arg0, arg1, arg2, success, error) {
40
44
  exec(success, error, 'emiAdmobPlugin', 'loadRewardedInterstitialAd', [arg0, arg1, arg2]);
41
45
  };
42
46
 
43
- exports.showRewardedInterstitialAd = function (arg0, success, error) {
44
- exec(success, error, 'emiAdmobPlugin', 'showRewardedInterstitialAd', [arg0]);
47
+ exports.showRewardedInterstitialAd = function (success, error) {
48
+ exec(success, error, 'emiAdmobPlugin', 'showRewardedInterstitialAd', []);
45
49
  };
46
50
 
47
- exports.getConsentRequest = function (arg0, success, error) {
48
- exec(success, error, 'emiAdmobPlugin', 'getConsentRequest', [arg0]);
51
+ exports.getConsentRequest = function (success, error) {
52
+ exec(success, error, 'emiAdmobPlugin', 'getConsentRequest', []);
49
53
  };
50
54
 
51
- exports.consentReset = function (arg0, success, error) {
52
- exec(success, error, 'emiAdmobPlugin', 'consentReset', [arg0]);
55
+ exports.consentReset = function (success, error) {
56
+ exec(success, error, 'emiAdmobPlugin', 'consentReset', []);
53
57
  };
54
58
 
55
59
  exports.targeting = function (arg0, arg1, arg2, success, error) {
56
60
  exec(success, error, 'emiAdmobPlugin', 'targeting', [arg0, arg1, arg2]);
61
+ };
62
+
63
+ exports.globalSettings = function (arg0, arg1, arg2, success, error) {
64
+ exec(success, error, 'emiAdmobPlugin', 'globalSettings', [arg0, arg1, arg2]);
57
65
  };
@@ -1,296 +0,0 @@
1
- <html>
2
- <head>
3
- <script type="text/javascript" src="cordova.js"></script>
4
- </head>
5
- <body>
6
-
7
- <script>
8
-
9
-
10
- // load App Open Ad
11
-
12
- let loadAppOpenAd = () => {
13
- cordova.plugins.emiAdmobPlugin.loadAppOpenAd(
14
- appOpenAdUnitId = "ca-app-pub-3940256099942544/3419835294",
15
- npa = "1", // String | 0 | 1
16
- responseInfo = true, // boolean
17
-
18
- (info) => { alert(info) },
19
- (error) => { alert(error)
20
-
21
- });
22
- }
23
-
24
- // Show App Open Ad
25
-
26
- let showAppOpenAd = () => {
27
- cordova.plugins.emiAdmobPlugin.showAppOpenAd();
28
- }
29
-
30
-
31
- /// setting banner size:
32
- /*
33
- BANNER
34
- FLUID
35
- LARGE_BANNER
36
- MEDIUM_RECTANGLE
37
- FULL_BANNER
38
- LEADERBOARD
39
- (Smart Banners = DEPRECATED)
40
- Inline_adaptive
41
- Anchored_adaptive
42
- default: Anchored_FULL_WIDTH
43
-
44
- adaptiveWidth = 320 // number (only adaptive banner)
45
-
46
- */
47
- /// setting banner position:
48
- /*
49
- top-right
50
- top-center
51
- left
52
- center
53
- right
54
- bottom-center
55
- bottom-right
56
- default: "bottom-left"
57
- */
58
-
59
- // Banner Adaptive
60
-
61
- let showBannerAdaptive = () => {
62
- cordova.plugins.emiAdmobPlugin.showBannerAd(
63
- bannerAdUnitId = "ca-app-pub-3940256099942544/6300978111",
64
- npa = "1", // String | 0 | 1
65
- position = "bottom-center",
66
- size = "Anchored_FULL_WIDTH", // | Inline_adaptive | Anchored_adaptive | default: Anchored_FULL_WIDTH
67
- adaptiveWidth = 320,
68
- responseInfo = true, // boolean
69
-
70
- (info) => { alert(info) },
71
- (error) => { alert(error)
72
-
73
- });
74
- }
75
-
76
- // not Adaptive banner
77
-
78
- let showBannerNotAdaptive = () => {
79
- cordova.plugins.emiAdmobPlugin.showBannerAd(
80
- bannerAdUnitId = "ca-app-pub-3940256099942544/6300978111",
81
- npa = "1", // String | 0 | 1
82
- position = "bottom-center",
83
- size = "FLUID",
84
- responseInfo = true, // boolean
85
-
86
- (info) => { alert(info) },
87
- (error) => { alert(error)
88
-
89
- });
90
- }
91
-
92
- // Remove Banner
93
-
94
- let removeBannerAd = () => {
95
- cordova.plugins.emiAdmobPlugin.removeBannerAd();
96
- }
97
-
98
-
99
- // Load Interstitial Ad
100
-
101
- let loadInterstitialAd = () => {
102
- cordova.plugins.emiAdmobPlugin.loadInterstitialAd(
103
- interstitialAdAdUnitId = "ca-app-pub-3940256099942544/1033173712",
104
- npa = "1", // String | 0 | 1
105
- responseInfo = true, // boolean
106
-
107
- (info) => { alert(info) },
108
- (error) => { alert(error)
109
-
110
- });
111
- }
112
-
113
- // Show Interstitial Ad
114
-
115
- let showInterstitialAd = () => {
116
- cordova.plugins.emiAdmobPlugin.showInterstitialAd();
117
- }
118
-
119
- // load Rewarded Interstitial Ad
120
-
121
- let loadRewardedInterstitialAd = () => {
122
- cordova.plugins.emiAdmobPlugin.loadRewardedInterstitialAd(
123
- rewardedInterstitialAdUnitId = "ca-app-pub-3940256099942544/5354046379",
124
- npa = "1", // String | 0 | 1
125
- responseInfo = true, // boolean
126
-
127
- (info) => { alert(info) },
128
- (error) => { alert(error)
129
-
130
- });
131
- }
132
-
133
-
134
- // Show Rewarded Interstitial Ad
135
-
136
- const showRewardedInterstitialAd = () => {
137
- cordova.plugins.emiAdmobPlugin.showRewardedInterstitialAd();
138
- }
139
-
140
- // Load Rewarded Ad
141
-
142
- let loadRewardedAd = () => {
143
- cordova.plugins.emiAdmobPlugin.loadRewardedAd(
144
- rewardedAdAdUnitId = "ca-app-pub-3940256099942544/5224354917",
145
- npa = "1", // String | 0 | 1
146
- responseInfo = true, // boolean
147
-
148
-
149
- (info) => { alert(info) },
150
- (error) => { alert(error)
151
-
152
- });
153
- }
154
-
155
- // Show Rewarded Ad
156
-
157
- let showRewardedAd = () => {
158
- cordova.plugins.emiAdmobPlugin.showRewardedAd();
159
- }
160
-
161
-
162
-
163
- document.addEventListener("deviceready", function(){
164
-
165
- // Before loading ads, have your app initialize the Google Mobile Ads SDK by calling
166
- // This needs to be done only once, ideally at app launch.
167
-
168
- cordova.plugins.emiAdmobPlugin.initialize();
169
-
170
- document.addEventListener('on.SdkInitializationComplete', () => {
171
-
172
- alert("on Sdk Initialization Complete");
173
-
174
-
175
- });
176
-
177
- // AppOpenAd EVEN
178
-
179
- /*
180
- on.open.loaded
181
- on.open.failed.loaded
182
- on.open.dismissed
183
- on.open.failed.show
184
- on.open.show
185
- */
186
-
187
-
188
- document.addEventListener('on.open.loaded', () => {
189
-
190
- alert("on app open loaded");
191
-
192
- });
193
-
194
-
195
-
196
- // BANNER EVENT
197
-
198
- /*
199
- on.bannerAdClicked
200
- on.bannerAdClosed
201
- on.bannerAdFailedToLoad
202
- on.bannerAdImpression
203
- on.bannerAdLoaded
204
- on.bannerAdOpened
205
- */
206
- document.addEventListener('on.bannerAdLoaded', () => {
207
-
208
- alert("on banner Ad Loaded");
209
-
210
- });
211
-
212
-
213
-
214
- // Interstitial EVENT
215
-
216
- /*
217
- on.InterstitialAdLoaded
218
- on.InterstitialAdFailedToLoad
219
- on.InterstitialAdClicked
220
- on.InterstitialAdDismissedFullScreenContent
221
- on.InterstitialAdFailedToShowFullScreenContent
222
- on.InterstitialAdImpression
223
- on.InterstitialAdShowedFullScreenContent
224
- */
225
-
226
- document.addEventListener('on.InterstitialAdLoaded', () => {
227
-
228
- alert("on Interstitial Ad Loaded");
229
-
230
- });
231
-
232
-
233
- // Rewarded Interstitial EVENT
234
-
235
- /*
236
- on.RewardedInterstitialAdLoaded
237
- on.RewardedInterstitialAdFailedToLoad
238
- on.rewardedInterstitialAdClicked
239
- on.rewardedInterstitialAdDismissedFullScreenContent
240
- on.rewardedInterstitialAdFailedToShowFullScreenContent
241
- on.rewardedInterstitialAdImpression
242
- on.rewardedInterstitialAdShowedFullScreenContent
243
- on.rewardedInterstitial.rewarded
244
- */
245
-
246
- document.addEventListener('on.RewardedInterstitialAdLoaded', () => {
247
-
248
- alert("on Rewarded Interstitial Loaded");
249
-
250
- });
251
-
252
-
253
- // Rewarded EVENT
254
-
255
- /*
256
- on.RewardedAdFailedToLoad
257
- on.RewardedAdLoaded
258
- on.rewardedAdClicked
259
- on.rewardedAdDismissedFullScreenContent
260
- on.rewardedAdFailedToShowFullScreenContent
261
- on.rewardedAdImpression
262
- on.rewardedAdShowedFullScreenContent
263
- on.rewarded.rewarded
264
- */
265
-
266
- document.addEventListener('on.RewardedAdLoaded', () => {
267
-
268
- alert("on Rewarded Ad Loaded");
269
-
270
- });
271
-
272
-
273
-
274
- }, false);
275
-
276
- </script>
277
-
278
- <p> <button onclick="loadAppOpenAd();">load App Open Ad</button></p>
279
- <p> <button onclick="showAppOpenAd();">Show App Open Ad</button></p>
280
-
281
- <p> <button onclick="showBannerAdaptive();">Show Banner adaptive</button></p>
282
- <p> <button onclick="showBannerNotAdaptive();">show Banner No Adaptive</button></p>
283
- <p> <button onclick="removeBannerAd();">remove Banner Ad</button></p>
284
-
285
- <p> <button onclick="loadInterstitialAd();">Load Interstitial Ad</button></p>
286
- <p> <button onclick="showInterstitialAd();">Show Interstitial Ad</button></p>
287
-
288
- <p> <button onclick="loadRewardedInterstitialAd();">Load Rewarded Interstitial</button></p>
289
- <p> <button onclick="showRewardedInterstitialAd();">Show Rewarded Interstitial</button></p>
290
-
291
- <p> <button onclick="loadRewardedAd();">Load Rewarded Ad</button></p>
292
- <p> <button onclick="showRewardedAd();">Show Rewarded Ad</button></p>
293
-
294
-
295
- </body>
296
- </html>