Events

appfeel edited this page Dec 23, 2014 · 1 revision

AdMobAds Cordova library will use the same events for Android as for iOS (the iOS ones are mapped to the Android ones). See Google Docs for more info.

To listen to any of those events you can use:

    document.addEventListener(admob.events.onAdLoaded, function (e) { });

admob.events.onAdLoaded

Called when an ad is received.

  • e: JSON object.
    Example: { adType : "banner" }
    • adType can be admob.AD_TYPE.BANNER or admob.AD_TYPE.INTERSTITIAL

admob.events.onAdFailedToLoad

Called when an ad request failed.

  • e: JSON object.
    Example: { adType : "[string]", error : [integer], reason : "[string]" }
    • adType can be admob.AD_TYPE.BANNER or admob.AD_TYPE.INTERSTITIAL
    • error is the error code and is usually one of the following:
      • AdRequest.ERROR_CODE_INTERNAL_ERROR
      • AdRequest.ERROR_CODE_INVALID_REQUEST
      • AdRequest.ERROR_CODE_NETWORK_ERROR
      • AdRequest.ERROR_CODE_NO_FILL
    • reason is an english string with the reason of the error (for logging purposes).

admob.events.onAdOpened

Called when an ad opens an overlay that covers the screen. Please note that onPause event is raised when an interstitial is shown.

  • e: JSON object.
    Example: { adType : "banner" }
    • adType can be admob.AD_TYPE.BANNER or admob.AD_TYPE.INTERSTITIAL

admob.events.onAdClosed

Called when the user is about to return to the application after clicking on an ad. Please note that onResume event is raised when an interstitial is closed.

  • e: JSON object.
    Example: { adType : "banner" }
    • adType can be admob.AD_TYPE.BANNER or admob.AD_TYPE.INTERSTITIAL

admob.events.onAdLeftApplication

Called when an ad leaves the application (e.g., to go to the browser).

  • e: JSON object.
    Example: { adType : "banner" }
    • adType can be admob.AD_TYPE.BANNER or admob.AD_TYPE.INTERSTITIAL

admob.events.onInAppPurchaseRequested

Called when the user clicks the buy button of an in-app purchase ad. You shoud complete the transaction by calling admob.recordResolution(...) or admob.recordPlayBillingResolution(...).

  • e: JSON object.
    Example: { adType : "banner" }
    • adType can be admob.AD_TYPE.BANNER or admob.AD_TYPE.INTERSTITIAL