Skip to Content
defold-typescript libraries
AppLovin

AppLovin/AppLovin-MAX-Defold/applovin

Functions and constants for interacting with AppLovin SDK.

  • GitHub: AppLovin/AppLovin-MAX-Defold — pinned to release (released while Defold 1.6.4 was current)
    1. Pick a release from AppLovin/AppLovin-MAX-Defold releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as applovin from "applovin"
  • Asset Portal: AppLovin-MAX-Defold

Functions

applovin.initialize(sdk_key: string)

Initialize the AppLovin SDK with the provided SDK key.

Parameters

  • sdk_key: string

applovin.set_callback(callback: function)

Sets a callback function for receiving events from the SDK. Call applovin.set_callback(nil) to remove callback

Parameters

  • callback: function — Callback function that is executed on any event in the SDK.
    • self: object — The calling script instance
    • name: string — One of the following types of events. "OnSdkInitializedEvent", "OnCmpCompletedEvent", "OnInterstitialAdLoadedEvent", "OnInterstitialAdLoadFailedEvent", "OnInterstitialAdDisplayedEvent", "OnInterstitialAdDisplayFailedEvent", "OnInterstitialAdHiddenEvent", "OnInterstitialAdClickedEvent", "OnInterstitialAdRevenuePaidEvent", "OnRewardedAdLoadedEvent", "OnRewardedAdLoadFailedEvent", "OnRewardedAdDisplayedEvent", "OnRewardedAdDisplayFailedEvent", "OnRewardedAdHiddenEvent", "OnRewardedAdClickedEvent", "OnRewardedAdReceivedRewardEvent", "OnRewardedAdRevenuePaidEvent", "OnBannerAdLoadedEvent", "OnBannerAdLoadFailedEvent", "OnBannerAdClickedEvent", "OnBannerAdExpandedEvent", "OnBannerAdCollapsedEvent", "OnBannerAdRevenuePaidEvent", "OnMRecAdLoadedEvent", "OnMRecAdLoadFailedEvent", "OnMRecAdClickedEvent", "OnMRecAdExpandedEvent", "OnMRecAdCollapsedEvent", "OnMRecAdRevenuePaidEvent",
    • params: table — A table holding the data of the event. "OnSdkInitializedEvent" { "countryCode" - string, country code for this user "consentFlowUserGeography" - number, user's geography used to determine the type of consent flow shown to the user. Possible values are applovin.CONSENT_FLOW_USER_GEOGRAPHY_UNKNOWN, applovin.CONSENT_FLOW_USER_GEOGRAPHY_GDPR, applovin.CONSENT_FLOW_USER_GEOGRAPHY_OTHER "isTestModeEnabled" - boolean, whether or not test mode is enabled for this session "appTrackingStatus" - number, ios only, whether or not the user authorizes access to app-related data that can be used for tracking the user or the device. Possible values are applovin.APP_TRACKING_TRANSPARENCY_STATUS_UNAVAILABLE, applovin.APP_TRACKING_TRANSPARENCY_STATUS_NOT_DETERMINED, applovin.APP_TRACKING_TRANSPARENCY_STATUS_RESTRICTED, applovin.APP_TRACKING_TRANSPARENCY_STATUS_DENIED, applovin.APP_TRACKING_TRANSPARENCY_STATUS_AUTHORIZED }, "OnCmpCompletedEvent" - empty table on successful completion OR { "code" - number, error code "message" - string, error message "cmpCode" - number, error code returned by the CMP "cmpMessage" - string, error message returned by the CMP } Ad loaded, displayed, hidden, clicked, expanded, collapsed, revenue paid event { "adUnitIdentifier" - string, ad unit id for which this ad was loaded. Guaranteed not to be null "networkName" - string, the ad network for which this ad was loaded from. Guaranteed not to be null "creativeIdentifier" - string, the creative id tied to the ad, if any. You can report creative issues to the corresponding ad network using this id "placement" - string, the ad placement which was set for this ad. May be null "revenue" - number, the ad’s revenue amount. In the case where no revenue amount exists, or it is not available yet, will return a value of 0 } "OnRewardedAdReceivedRewardEvent" will receive the following parameters in addition to above parameters { "label" - string, currency label "amount" - number, reward amount } Ad load failed, displayed failed event { "adUnitIdentifier" - string, ad unit id for this ad "code" - number, error code for the error "message" - string, error message for the error }

applovin.is_initialized(): boolean

Checks if the AppLovin SDK has been initialized.

Returns

  • is_initialized: boolean — Returns true if the SDK is initialized, false otherwise.

applovin.show_mediation_debugger()

Displays the Mediation Debugger.

Sets whether the user has provided consent for interest-based advertising.

Parameters

  • has_user_consent: boolean

Checks if the user has provided consent for interest-based advertising.

Returns

  • has_user_consent: boolean

applovin.set_is_age_restricted_user(is_age_restricted_user: boolean)

Sets whether the user is considered to be in an age-restricted category.

Parameters

  • is_age_restricted_user: boolean

applovin.is_age_restricted_user(): boolean

Checks if the user is considered to be in an age-restricted category.

Returns

  • is_age_restricted_user: boolean

applovin.set_do_not_sell(do_not_sell: boolean)

Sets whether the user has chosen to opt out of the sale of their personal information.

Parameters

  • do_not_sell: boolean

applovin.is_do_not_sell(): boolean

Checks if the user has chosen to opt out of the sale of their personal information.

Returns

  • do_not_sell: boolean

applovin.set_terms_and_privacy_policy_flow_enabled(enabled: boolean)

Enables or disables the MAX Terms and Privacy Policy Flow.

Parameters

  • enabled: boolean

applovin.set_privacy_policy_url(url_string: string)

Sets the privacy policy URL for MAX Terms and Privacy Policy Flow.

Parameters

  • url_string: string

applovin.set_terms_of_service_url(url_string: string)

Sets terms of service URL for MAX Terms and Privacy Policy Flow.

Parameters

  • url_string: string

Sets the user geography for debugging purposes in the consent flow.

Parameters

  • user_geography_string: string — gdpr other

applovin.show_cmp_for_existing_user()

Shows the integrated consent management platform (CMP) flow for existing users.

applovin.has_supported_cmp(): boolean

Checks if a supported consent management platform is integrated.

Returns

  • has_supported_cmp: boolean

applovin.is_tablet(): boolean

Checks if the current device is a tablet.

Returns

  • is_tablet: boolean

applovin.set_user_id(user_id: string)

Set internal user ID before initializing the SDK.

Parameters

  • user_id: string

applovin.set_muted(muted: boolean)

Sets whether ads from certain mediated SDK networks should be muted.

Parameters

  • muted: boolean

applovin.is_muted(): boolean

Checks if ads are set to be muted.

Returns

  • isMuted: boolean

applovin.set_verbose_logging_enabled(enabled: boolean)

Enables or disables verbose logging.

Parameters

  • enabled: boolean

applovin.is_verbose_logging_enabled(): boolean

Checks if verbose logging is enabled.

Returns

  • is_verbose_logging_enabled: boolean

applovin.set_creative_debugger_enabled(enabled: boolean)

Enables or disables the creative debugger.

Parameters

  • enabled: boolean

applovin.set_test_device_advertising_ids(advertising_ids: array, count: number)

Enables devices to receive test ads.

Parameters

  • advertising_ids: array — Array of device IDs. IDFA for iOS / GAID for Android
  • count: number — Number of IDs in the array.

applovin.track_event(event: string, parameters: string)

Tracks a custom event.

Parameters

  • event: string
  • parameters: string — JSON string of parameters.

applovin.load_interstitial(ad_unit_id: string)

Loads an interstitial ad for the given ad unit ID.

Parameters

  • ad_unit_id: string

applovin.is_interstitial_ready(ad_unit_id: string): boolean

Checks if an interstitial ad is ready to be shown.

Parameters

  • ad_unit_id: string

Returns

  • is_ready: boolean

applovin.show_interstitial(2 overloads)

  1. (ad_unit_id: string)

    Shows an interstitial ad for the given ad unit ID.

    Parameters

    • ad_unit_id: string
  2. (ad_unit_id: string, placement: string)

    Shows an interstitial ad for the given ad unit ID and the placement name.

    Parameters

    • ad_unit_id: string
    • placement: string

applovin.set_interstitial_extra_parameter(ad_unit_id: string, key: string, value: string)

Sets extra parameters for an interstitial ad.

Parameters

  • ad_unit_id: string
  • key: string
  • value: string

applovin.load_rewarded_ad(ad_unit_id: string)

Loads a rewarded ad for the given ad unit ID.

Parameters

  • ad_unit_id: string

applovin.is_rewarded_ad_ready(ad_unit_id: string): boolean

Checks if a rewarded ad is ready to be shown.

Parameters

  • ad_unit_id: string

Returns

  • is_ready: boolean

applovin.show_rewarded_ad(2 overloads)

  1. (ad_unit_id: string)

    Shows a rewarded ad for the given ad unit ID.

    Parameters

    • ad_unit_id: string
  2. (ad_unit_id: string, placement: string)

    Shows a rewarded ad for the given ad unit ID and the placement name.

    Parameters

    • ad_unit_id: string
    • placement: string

applovin.set_rewarded_ad_extra_parameter(ad_unit_id: string, key: string, value: string)

Sets extra parameters for a rewarded ad.

Parameters

  • ad_unit_id: string
  • key: string
  • value: string

applovin.create_banner(ad_unit_id: string, banner_position: string)

Create and load a banner ad.

Parameters

  • ad_unit_id: string
  • banner_position: string — Possible options are "top_left", "top_center", "top_right", "centered", "bottom_left", "bottom_center", "bottom_right"

applovin.set_banner_background_color(ad_unit_id: string, hex_color_code: string)

Sets the background color of a banner ad with the Ad Unit ID.

Parameters

  • ad_unit_id: string
  • hex_color_code: string — Supported formats are "#RRGGBB" and "#AARRGGBB".

applovin.set_banner_placement(ad_unit_id: string, placement: string)

Sets the placement name for a banner ad unit.

Parameters

  • ad_unit_id: string
  • placement: string

applovin.set_banner_extra_parameter(ad_unit_id: string, key: string, value: string)

Sets extra parameters for a banner ad.

Parameters

  • ad_unit_id: string
  • key: string
  • value: string

applovin.update_banner_position(ad_unit_id: string, banner_position: string)

Updates the position of a banner ad.

Parameters

  • ad_unit_id: string
  • banner_position: string — Possible options are "top_left", "top_center", "top_right", "centered", "bottom_left", "bottom_center", "bottom_right"

applovin.start_banner_auto_refresh(ad_unit_id: string)

Starts auto refresh for a banner ad.

Parameters

  • ad_unit_id: string

applovin.stop_banner_auto_refresh(ad_unit_id: string)

Stops auto refresh for a banner ad.

Parameters

  • ad_unit_id: string

applovin.show_banner(ad_unit_id: string)

Displays a banner ad.

Parameters

  • ad_unit_id: string

applovin.hide_banner(ad_unit_id: string)

Hides a banner ad.

Parameters

  • ad_unit_id: string

applovin.destroy_banner(ad_unit_id: string)

Destroys a banner ad.

Parameters

  • ad_unit_id: string

applovin.create_mrec(ad_unit_id: string, mrec_position: string)

Creates an MRec ad with the specified ad unit ID and position.

Parameters

  • ad_unit_id: string
  • mrec_position: string — Possible options are "top_left", "top_center", "top_right", "centered", "bottom_left", "bottom_center", "bottom_right"

applovin.set_mrec_placement(ad_unit_id: string, placement: string)

Sets the placement name for a MRec ad unit.

Parameters

  • ad_unit_id: string
  • placement: string

applovin.set_mrec_extra_parameter(ad_unit_id: string, key: string, value: string)

Sets extra parameters for an MRec ad.

Parameters

  • ad_unit_id: string
  • key: string
  • value: string

applovin.update_mrec_position(ad_unit_id: string, mrec_position: string)

Updates the position of an MRec ad.

Parameters

  • ad_unit_id: string
  • mrec_position: string — Possible options are "top_left", "top_center", "top_right", "centered", "bottom_left", "bottom_center", "bottom_right"

applovin.start_mrec_auto_refresh(ad_unit_id: string)

Starts auto refresh for an MRec ad.

Parameters

  • ad_unit_id: string

applovin.stop_mrec_auto_refresh(ad_unit_id: string)

Stops auto refresh for an MRec ad.

Parameters

  • ad_unit_id: string

applovin.show_mrec(ad_unit_id: string)

Displays an MRec ad.

Parameters

  • ad_unit_id: string

applovin.hide_mrec(ad_unit_id: string)

Hides an MRec ad.

Parameters

  • ad_unit_id: string

applovin.destroy_mrec(ad_unit_id: string)

Destroys an MRec ad.

Parameters

  • ad_unit_id: string

Constants

applovin.CONSENT_FLOW_USER_GEOGRAPHY_UNKNOWN

User's geography is unknown.

applovin.CONSENT_FLOW_USER_GEOGRAPHY_GDPR

The user is in GDPR region.

applovin.CONSENT_FLOW_USER_GEOGRAPHY_OTHER

The user is in a non-GDPR region.

applovin.APP_TRACKING_TRANSPARENCY_STATUS_UNAVAILABLE

Device is on iOS before iOS14, AppTrackingTransparency.framework is not available.

applovin.APP_TRACKING_TRANSPARENCY_STATUS_NOT_DETERMINED

The user has not yet received an authorization request to authorize access to app-related data that can be used for tracking the user or the device.

applovin.APP_TRACKING_TRANSPARENCY_STATUS_RESTRICTED

Authorization to access app-related data that can be used for tracking the user or the device is restricted.

applovin.APP_TRACKING_TRANSPARENCY_STATUS_DENIED

The user denies authorization to access app-related data that can be used for tracking the user or the device.

applovin.APP_TRACKING_TRANSPARENCY_STATUS_AUTHORIZED

The user authorizes access to app-related data that can be used for tracking the user or the device.

On this page

Functionsapplovin.initialize(sdk_key: string)applovin.set_callback(callback: function)applovin.is_initialized(): booleanapplovin.show_mediation_debugger()applovin.set_has_user_consent(has_user_consent: boolean)applovin.has_user_consent(): booleanapplovin.set_is_age_restricted_user(is_age_restricted_user: boolean)applovin.is_age_restricted_user(): booleanapplovin.set_do_not_sell(do_not_sell: boolean)applovin.is_do_not_sell(): booleanapplovin.set_terms_and_privacy_policy_flow_enabled(enabled: boolean)applovin.set_privacy_policy_url(url_string: string)applovin.set_terms_of_service_url(url_string: string)applovin.set_consent_flow_debug_user_geography(user_geography_string: string)applovin.show_cmp_for_existing_user()applovin.has_supported_cmp(): booleanapplovin.is_tablet(): booleanapplovin.set_user_id(user_id: string)applovin.set_muted(muted: boolean)applovin.is_muted(): booleanapplovin.set_verbose_logging_enabled(enabled: boolean)applovin.is_verbose_logging_enabled(): booleanapplovin.set_creative_debugger_enabled(enabled: boolean)applovin.set_test_device_advertising_ids(advertising_ids: array, count: number)applovin.track_event(event: string, parameters: string)applovin.load_interstitial(ad_unit_id: string)applovin.is_interstitial_ready(ad_unit_id: string): booleanapplovin.show_interstitial(2 overloads)applovin.set_interstitial_extra_parameter(ad_unit_id: string, key: string, value: string)applovin.load_rewarded_ad(ad_unit_id: string)applovin.is_rewarded_ad_ready(ad_unit_id: string): booleanapplovin.show_rewarded_ad(2 overloads)applovin.set_rewarded_ad_extra_parameter(ad_unit_id: string, key: string, value: string)applovin.create_banner(ad_unit_id: string, banner_position: string)applovin.set_banner_background_color(ad_unit_id: string, hex_color_code: string)applovin.set_banner_placement(ad_unit_id: string, placement: string)applovin.set_banner_extra_parameter(ad_unit_id: string, key: string, value: string)applovin.update_banner_position(ad_unit_id: string, banner_position: string)applovin.start_banner_auto_refresh(ad_unit_id: string)applovin.stop_banner_auto_refresh(ad_unit_id: string)applovin.show_banner(ad_unit_id: string)applovin.hide_banner(ad_unit_id: string)applovin.destroy_banner(ad_unit_id: string)applovin.create_mrec(ad_unit_id: string, mrec_position: string)applovin.set_mrec_placement(ad_unit_id: string, placement: string)applovin.set_mrec_extra_parameter(ad_unit_id: string, key: string, value: string)applovin.update_mrec_position(ad_unit_id: string, mrec_position: string)applovin.start_mrec_auto_refresh(ad_unit_id: string)applovin.stop_mrec_auto_refresh(ad_unit_id: string)applovin.show_mrec(ad_unit_id: string)applovin.hide_mrec(ad_unit_id: string)applovin.destroy_mrec(ad_unit_id: string)Constantsapplovin.CONSENT_FLOW_USER_GEOGRAPHY_UNKNOWNapplovin.CONSENT_FLOW_USER_GEOGRAPHY_GDPRapplovin.CONSENT_FLOW_USER_GEOGRAPHY_OTHERapplovin.APP_TRACKING_TRANSPARENCY_STATUS_UNAVAILABLEapplovin.APP_TRACKING_TRANSPARENCY_STATUS_NOT_DETERMINEDapplovin.APP_TRACKING_TRANSPARENCY_STATUS_RESTRICTEDapplovin.APP_TRACKING_TRANSPARENCY_STATUS_DENIEDapplovin.APP_TRACKING_TRANSPARENCY_STATUS_AUTHORIZED