VelocityAds
setUserId()
| Parameter | Type | Required | Description |
|---|---|---|---|
userId | String? | No | User identifier |
initSDK() for best performance.
initSDK()
| Parameter | Type | Required | Description |
|---|---|---|---|
context | Context | Yes | Application context |
initRequest | VelocityAdsInitRequest | Yes | Built via VelocityAdsInitRequest.Builder |
listener | VelocityAdsInitListener | Yes | Receives init success or failure |
Utility Methods
| Method | Description |
|---|---|
isInitialized(): Boolean | Returns true if the SDK completed initialization successfully |
getSdkVersion(): String | Returns the SDK version string |
setPluginInfo(type, version) | Sets plugin metadata for cross-platform wrapper tracking. Call before initSDK() |
setDoNotSell(flag: Boolean) | Sets the CCPA “Do Not Sell” preference |
setConsent(flag: Boolean) | Sets the GDPR consent preference |
VelocityNativeAd
The core ad object. Create one instance per ad placement, then callloadAd().
loadAd() — Raw data
registerViewForInteraction() inside onAdLoaded.
loadAd() — Compose card
adRequest must be a VelocityNativeAdViewRequest. Delivers a @Composable lambda on success.
loadAd() — View card
adRequest must be a VelocityNativeAdViewRequest. Delivers a ready-to-display android.view.View on success.
registerViewForInteraction()
| Parameter | Type | Required | Description |
|---|---|---|---|
adView | View | Yes | Root view — used for impression visibility detection |
clickableViews | List<View> | Yes | Views that trigger onAdClicked when tapped |
unregisterViewForInteraction()
destroyAd()
onDestroy() for every loaded ad.
Models
VelocityNativeAdRequest
VelocityNativeAdViewRequest
Extends VelocityNativeAdRequest with size and theming for rendered ad formats.
NativeAd (ad creative data)
Accessed via VelocityNativeAd.data after a successful load.
| Field | Type | Description |
|---|---|---|
adId | String | Unique ad load identifier |
title | String | Ad headline |
description | String | Ad body text |
callToAction | String | CTA button text |
advertiserName | String | Advertiser/brand name |
sponsoredLabel | String | Sponsorship label |
badgeLabel | String | Badge text (e.g. “ad”) |
advertiserIconUrl | String | Advertiser logo/icon URL |
largeImageUrl | String? | Main ad image URL (optional) |
squareImageUrl | String? | Square ad image URL (optional) |
clickUrl | String | URL opened on ad click |
impressionUrl | String | Impression tracking URL |
VelocityAdViewSize
AdConfiguration
Listeners
VelocityAdsInitListener
VelocityAdsInitRequest.Builder
VelocityNativeAdListener
| Method | Description |
|---|---|
onAdLoaded | Main thread. Ad loaded — nativeAd.data is populated. Call registerViewForInteraction here |
onAdFailedToLoad | Ad request failed. nativeAd.data is not accessible |
onAdImpression | Fired once when the registered adView is ≥ 50% visible on screen |
onAdClicked | Fired each time the user taps a registered clickable view |
VelocityNativeAdComposeListener
VelocityNativeAdViewListener
Error Codes
VelocityAdsError
VelocityAdsErrorCode
| Code | Constant | Meaning |
|---|---|---|
| 1000 | INVALID_URL | Malformed URL |
| 1001 | NETWORK_ERROR | Network request failed |
| 1002 | JSON_PARSE_ERROR | Response JSON could not be parsed |
| 1003 | INVALID_RESPONSE | Response structure is invalid |
| 1004 | EMPTY_RESPONSE_BODY | Server returned an empty body |
| 1005 | SERVER_ERROR_FIELD | Server returned an error field |
| 1006 | HTTP_FAILURE | HTTP status code indicates failure |
| 2000 | INVALID_APP_KEY | appKey is empty or blank |
| 2001 | SDK_NOT_INITIALIZED | loadAd called before initSDK |
| 2002 | SDK_INITIALIZATION_IN_PROGRESS | initSDK called while already initializing |
| 2003 | LOAD_ALREADY_IN_PROGRESS | loadAd called while already loading |
| 2004 | LOAD_SERVICE_UNAVAILABLE | Internal bidder service not available |
| 2005 | INVALID_AD_RESPONSE | Ad response is missing required data |
| 2006 | NO_FILL | No ad available for the given context |
| 2007 | INTERNAL_ERROR | Unexpected internal SDK error |
| 2008 | INVALID_AD_REQUEST | Wrong request type passed to a load method |
| 2009 | WATERFALL_LOAD_FAILED | Waterfall load failed |

