Skip to content

API Reference

Per-platform reference for all public classes, methods, delegates, and types in the Sellwild SDK.


Table of Contents

  1. iOS (Swift)
  2. Android (Kotlin)
  3. React Native (TypeScript)
  4. Flutter (Dart)
  5. Core Types

iOS (Swift)

SellwildConfig

Primary configuration struct. All ad views and widgets read from this object.

swift
public struct SellwildConfig: Codable {
    // Required
    public var partnerCode: String
    public var listingsUrl: String

    // App identity
    public var apiBaseUrl: String               // default: "https://api.sellwild.com"
    public var appBundleId: String?
    public var appStoreUrl: String?

    // Prebid Server
    public var prebidServer: PrebidServerConfig?

    // Ad refresh
    public var adRefreshMax: Int                 // default: 0
    public var adRefreshMaxMobile: Int           // default: 0
    public var adRefreshInterval: TimeInterval   // default: 30.0
    public var maxFailedAuctions: Int            // default: 3

    // Privacy
    public var gppEnabled: Bool                  // default: false
    public var tcfVersion: Int                   // default: 0

    // Debug
    public var debug: Bool                       // default: false
}

Initializer:

swift
public init(partnerCode: String, listingsUrl: String)

For the complete list of fields, see Configuration Reference.


SellwildAdView (UIKit)

A UIView subclass that renders a single ad unit in a managed WebView.

Initializer:

swift
public init(config: SellwildConfig, adSize: AdSize, zoneId: String? = nil)
ParameterTypeDescription
configSellwildConfigSDK configuration.
adSizeAdSizeAd dimensions (e.g., .mrec300x250).
zoneIdString?Optional zone identifier for the ad slot.

Properties:

PropertyTypeDescription
delegateSellwildAdViewDelegate?Delegate for ad lifecycle callbacks.

Methods:

MethodDescription
load()Start or reload the ad auction. Call after the view is in the view hierarchy.
pause()Stop the refresh timer and pause WebView JavaScript execution. Call in viewDidDisappear.

Lifecycle notes:

  • The view manages its own WKWebView internally. Do not add subviews or modify its frame directly.
  • In deinit, the view invalidates its refresh timer and removes the WKScriptMessageHandler to break retain cycles.
  • Each instance uses a separate WKProcessPool. Ad sessions are isolated between instances.

SellwildAdViewDelegate

swift
@objc public protocol SellwildAdViewDelegate: AnyObject {
    @objc optional func sellwildAdViewDidLoad(_ adView: SellwildAdView)
    @objc optional func sellwildAdView(_ adView: SellwildAdView,
                                       didReceiveImpressionForZoneId zoneId: String)
    @objc optional func sellwildAdViewDidRecordClick(_ adView: SellwildAdView)
    @objc optional func sellwildAdView(_ adView: SellwildAdView,
                                       didFailWithError error: Error)
}
CallbackWhen It Fires
sellwildAdViewDidLoad(_:)Creative markup has been rendered in the WebView.
sellwildAdView(_:didReceiveImpressionForZoneId:)A viewable impression has been recorded (MRC standard).
sellwildAdViewDidRecordClick(_:)The user tapped the ad creative.
sellwildAdView(_:didFailWithError:)The auction returned no fill, or an error occurred during rendering.

All callbacks are dispatched on the main thread. All methods are optional (@objc optional).


SellwildAdBanner (SwiftUI)

A UIViewRepresentable wrapper around SellwildAdView for use in SwiftUI. Requires iOS 14+.

swift
SellwildAdBanner(
    config: config,
    adSize: .mrec300x250,
    zoneId: nil,
    onImpression: { /* ... */ },
    onError: { error in /* ... */ }
)
.frame(width: 300, height: 250)
ParameterTypeRequiredDescription
configSellwildConfigYesSDK configuration.
adSizeAdSizeYesAd dimensions.
zoneIdString?NoOptional zone identifier.
onImpression(() -> Void)?NoImpression callback.
onError((Error) -> Void)?NoError callback.

The view calls load() automatically when it appears. Refresh timers are managed internally.


SellwildWidgetView (UIKit)

A UIView subclass that renders the full Sellwild marketplace widget (listing carousel with embedded ad placements) in a WebView.

Properties:

PropertyTypeDescription
delegateSellwildWidgetViewDelegate?Delegate for widget lifecycle callbacks.

Methods:

MethodDescription
pause()Pause WebView and ad refresh.
resume()Resume WebView rendering.
destroy()Release all WebView resources. Do not use the instance after calling.

SellwildWidget (SwiftUI)

SwiftUI wrapper for the marketplace widget. Requires iOS 14+.

swift
SellwildWidget(
    config: config,
    onListingTap: { listing in /* ... */ },
    onLoad: { /* ... */ },
    onError: { error in /* ... */ }
)
.frame(height: 400)
ParameterTypeRequiredDescription
configSellwildConfigYesSDK configuration.
onListingTap((SellwildListing) -> Void)?NoCalled when the user taps a listing.
onLoad(() -> Void)?NoCalled when the widget finishes loading.
onError((Error) -> Void)?NoCalled on widget errors.

SellwildAPIClient

Singleton HTTP client for fetching marketplace listing data.

swift
// Singleton access
SellwildAPIClient.shared

// Callback-based (iOS 13+)
SellwildAPIClient.shared.fetchListings(config: config) { result in
    switch result {
    case .success(let response):
        // response.listings: [SellwildListing]
    case .failure(let error):
        // handle error
    }
}

// Async/await (iOS 15+)
let response = try await SellwildAPIClient.shared.fetchListings(config: config)

// Clear cached responses
SellwildAPIClient.shared.clearCache()
MethodReturn TypeDescription
fetchListings(config:completion:)Result<SellwildListingsResponse, Error>Fetch listings with completion handler.
fetchListings(config:) (async)SellwildListingsResponseFetch listings with async/await. Throws on error.
clearCache()VoidClear the internal response cache.

Responses are cached by URL. Subsequent calls with the same listingsUrl return the cached result. Call clearCache() before re-fetching for fresh data.


Android (Kotlin)

SellwildConfig

Data class for SDK configuration.

kotlin
data class SellwildConfig(
    val partnerCode: String,
    val listingsUrl: String,
    val appBundleId: String? = null,
    val appStoreUrl: String? = null,
    val prebidServer: PrebidServerConfig? = null,
    val adRefreshMax: Int = 0,
    val adRefreshMaxMobile: Int = 0,
    val adRefreshIntervalMs: Long = 30_000L,
    val maxFailedAuctions: Int = 3,
    val gppEnabled: Boolean = false,
    val tcfVersion: Int = 0,
    val debug: Boolean = false,
    // ... additional fields
)

For the complete list of fields, see Configuration Reference.


SellwildAdView

A FrameLayout subclass that renders a single ad unit.

Constructor:

kotlin
SellwildAdView(context: Context)

Setup:

kotlin
adView.setup(config: SellwildConfig, adSize: AdSize, zoneId: String? = null)

Properties:

PropertyTypeDescription
listenerSellwildAdView.Listener?Listener for ad lifecycle callbacks.

Methods:

MethodDescription
setup(config, adSize, zoneId?)Configure the ad view. Must be called before load().
load()Start or reload the ad auction.
pause()Pause WebView and stop refresh timer. Call in onPause().
resume()Resume WebView rendering. Call in onResume().
destroy()Release all WebView resources. Call in onDestroy(). The instance must not be used after this call.

SellwildAdView.Listener

kotlin
interface Listener {
    fun onAdLoaded(adView: SellwildAdView) {}
    fun onAdImpression(adView: SellwildAdView, zoneId: String) {}
    fun onAdClicked(adView: SellwildAdView) {}
    fun onAdFailed(adView: SellwildAdView, message: String) {}
}
CallbackWhen It Fires
onAdLoaded(adView)Creative fetched and rendered in the WebView.
onAdImpression(adView, zoneId)Viewable impression recorded.
onAdClicked(adView)User tapped the ad.
onAdFailed(adView, message)No fill or render error.

All callbacks are dispatched on the main thread. All methods have default (empty) implementations -- override only what you need.


SellwildWidgetView

A FrameLayout subclass that renders the full marketplace widget.

Methods:

MethodDescription
pause()Pause WebView and ad refresh.
resume()Resume WebView rendering.
destroy()Release all resources.

Listener:

kotlin
interface Listener {
    fun onWidgetLoaded() {}
    fun onListingTap(listing: SellwildListing) {}
    fun onAdImpression(zoneId: String) {}
    fun onError(message: String) {}
}

SellwildAPIClient

Singleton HTTP client using Kotlin coroutines.

kotlin
val client = SellwildAPIClient.getInstance(context)

// Suspend function -- call from a coroutine scope
val result: Result<SellwildListingsResponse> = client.fetchListings(config)

result.onSuccess { response ->
    // response.listings: List<SellwildListing>
}
result.onFailure { error ->
    // handle error
}

// Clear cache
client.clearCache()
MethodReturn TypeDescription
fetchListings(config)Result<SellwildListingsResponse>Suspend function. Switches to Dispatchers.IO internally.
clearCache()UnitClear the response cache.

SellwildWebViewCompat

Utility for multi-process WebView safety on Android 9+ (API 28+).

kotlin
// Call in Application.onCreate(), before any WebView is created
SellwildWebViewCompat.configureForMultiProcess(context)

React Native (TypeScript)

SellwildBanner

Standalone banner ad component. Renders a Prebid-powered ad in a WebView.

tsx
import { SellwildBanner, buildConfig } from '@sellwild/react-native-sdk';

<SellwildBanner
  config={buildConfig({ partnerCode: 'weatherbug', listingsUrl: '...' })}
  size="300x250"
  zoneId={12345}
  onImpression={() => {}}
  onError={(error) => {}}
  style={{ alignSelf: 'center' }}
/>
PropTypeRequiredDescription
configSellwildConfigYesFull config (call buildConfig() first).
sizeAdSizeYesAd dimensions string: "320x50", "300x250", "728x90", "160x600", "300x600", "1x1".
zoneIdnumberNoAd zone identifier.
onImpression() => voidNoImpression callback.
onError(error: Error) => voidNoError callback.
styleViewStyleNoReact Native style object.

SellwildWidget

Full marketplace widget with listing carousel and embedded ad placements.

tsx
import { SellwildWidget, type PartialSellwildConfig } from '@sellwild/react-native-sdk';

<SellwildWidget
  config={partialConfig}
  onListingPress={(listing) => {}}
  onAdImpression={(zoneId) => {}}
  onLoad={() => {}}
  onError={(error) => {}}
  style={{ height: 420 }}
/>
PropTypeRequiredDescription
configPartialSellwildConfigYesPartial config (calls buildConfig() internally).
onListingPress(listing: SellwildListing) => voidNoCalled when a listing is tapped.
onAdImpression(zoneId: string) => voidNoCalled on ad impression.
onLoad() => voidNoCalled when the widget finishes loading.
onError(error: Error) => voidNoCalled on widget errors.
styleViewStyleNoReact Native style object.

SellwildListingCard

Native listing card component for custom listing layouts.

tsx
import { SellwildListingCard } from '@sellwild/react-native-sdk';

<SellwildListingCard
  listing={listing}
  config={config}
  onPress={(listing) => {}}
  style={{ flex: 1 }}
/>
PropTypeRequiredDescription
listingSellwildListingYesListing data to render.
configSellwildConfigYesUsed for styling (colors, fonts).
onPress(listing: SellwildListing) => voidNoTap callback.
styleViewStyleNoReact Native style object.

useSellwildListings

React hook for fetching marketplace listings.

ts
import { useSellwildListings } from '@sellwild/react-native-sdk';

function ListingsScreen() {
  const { listings, loading, error, refresh } = useSellwildListings(config);
  // ...
}

Return type:

ts
interface UseSellwildListingsResult {
  listings: SellwildListing[];     // Fetched listing data
  config: Record<string, unknown>; // Remote widget configuration
  loading: boolean;                // True during fetch or refresh
  error: Error | null;             // Network or parse error, if any
  refresh: () => void;             // Trigger a cache-busting re-fetch
}

buildConfig

Utility function that applies default values to a partial configuration object.

ts
import { buildConfig, type SellwildConfig, type PartialSellwildConfig } from '@sellwild/react-native-sdk';

const config: SellwildConfig = buildConfig({
  partnerCode: 'weatherbug',
  listingsUrl: 'https://api.sellwild.com/listings/weatherbug',
});

SellwildBanner requires a full SellwildConfig (call buildConfig() first). SellwildWidget accepts PartialSellwildConfig and calls buildConfig() internally.


currencyToSymbol

ts
import { currencyToSymbol } from '@sellwild/react-native-sdk';

currencyToSymbol('USD'); // '$'
currencyToSymbol('EUR'); // '\u20ac'
currencyToSymbol('GBP'); // '\u00a3'

Flutter (Dart)

SellwildConfig

Immutable configuration class. All fields are final.

dart
final config = SellwildConfig(
  partnerCode: 'weatherbug',
  listingsUrl: 'https://api.sellwild.com/widget/listings?partner=weatherbug',
  appBundleId: 'com.aws.android',
  appStoreUrl: 'https://play.google.com/store/apps/details?id=com.aws.android',
  prebidServer: PrebidServerConfig(
    accountId: 'weatherbug',
    endpoint: 'https://prebid.sellwild.com/openrtb2/auction',
    bidders: ['appnexus', 'pubmatic', 'ix', 'rubicon', 'openx'],
    timeout: 1500,
  ),
);

Constructor accepts all fields from the Configuration Reference. The class is const-constructible when all arguments are compile-time constants.


SellwildWidget

The primary Flutter widget. Renders the full marketplace experience in a WebView.

dart
SellwildWidget(
  config: config,
  onListingTap: (SellwildListing listing) { /* ... */ },
  onAdImpression: (String zoneId) { /* ... */ },
  onLoad: () { /* ... */ },
  onError: (Object error) { /* ... */ },
)
ParameterTypeRequiredDescription
configSellwildConfigYesSDK configuration.
onListingTapvoid Function(SellwildListing)?NoCalled when a listing is tapped.
onAdImpressionvoid Function(String)?NoCalled on ad impression with zone ID.
onLoadvoid Function()?NoCalled when the widget finishes loading.
onErrorvoid Function(Object)?NoCalled on errors.

The widget expands to fill its parent. Wrap it in a SizedBox or Expanded to control dimensions:

dart
SizedBox(height: 400, child: SellwildWidget(config: config))

SellwildBanner

Standalone banner ad widget.

dart
SellwildBanner(
  config: config,
  adSize: SellwildAdSize.mrec300x250,
  zoneId: '12345',
  onImpression: () { /* ... */ },
  onClick: () { /* ... */ },
  onError: (Object error) { /* ... */ },
)
ParameterTypeRequiredDescription
configSellwildConfigYesSDK configuration.
adSizeSellwildAdSizeYesIAB standard ad dimensions.
zoneIdString?NoAd zone identifier.
onImpressionvoid Function()?NoCalled when the ad renders.
onClickvoid Function()?NoCalled when the user taps the ad.
onErrorvoid Function(Object)?NoCalled on errors.

SellwildListingCard

Native Flutter widget for rendering a single listing card.

dart
SellwildListingCard(
  listing: listing,
  config: config,
  onTap: (SellwildListing listing) { /* ... */ },
)
ParameterTypeRequiredDescription
listingSellwildListingYesListing data to render.
configSellwildConfigYesUsed for styling (colors, font size).
onTapvoid Function(SellwildListing)?NoCalled when the card is tapped.

The card renders at a fixed width of 160px with an image, price badge, and title. Customize appearance through SellwildConfig fields (priceColor, priceFontColor, fontSize).


SellwildAPIClient

Singleton HTTP client for fetching listing data.

dart
final client = SellwildAPIClient.instance;

// Fetch listings
final response = await client.fetchListings(config);
for (final listing in response.listings) {
  print('${listing.title} -- ${listing.displayPrice}');
}

// Clear cache
client.clearCache();

// Dispose (for test teardown)
client.dispose();
MethodReturn TypeDescription
fetchListings(config)Future<SellwildListingsResponse>Fetch listings. Caches by URL.
clearCache()voidClear the response cache.
dispose()voidClose the HTTP client. Call only in test teardown.

Error handling: Throws SellwildException on network or parsing errors.

dart
try {
  final response = await SellwildAPIClient.instance.fetchListings(config);
} on SellwildException catch (e) {
  debugPrint('API error: ${e.message}');
}

SellwildAdSize

Enum of supported ad dimensions.

dart
enum SellwildAdSize {
  banner320x50,          // 320 x 50  -- Mobile Banner
  mrec300x250,           // 300 x 250 -- Medium Rectangle
  leaderboard728x90,     // 728 x 90  -- Leaderboard
  halfPage300x600,       // 300 x 600 -- Half Page
  wideSkyscraper160x600, // 160 x 600 -- Wide Skyscraper
}

PrebidServerConfig

dart
class PrebidServerConfig {
  final String accountId;
  final String endpoint;
  final List<String> bidders;
  final int timeout;            // default: 1500
  final String? syncEndpoint;   // derived from endpoint if null
}

Core Types

These types are shared across all platforms. Field names may vary slightly per platform convention (camelCase vs snake_case).

SellwildListing

Represents a marketplace listing.

FieldTypeDescription
idStringUnique listing identifier.
statusStringListing status (e.g., "active").
titleStringListing title.
textString?Description body text.
urlString?Deep link to the listing detail page.
categoryIdString?Category identifier.
categoryGroupIdString?Category group identifier.
currencyString?ISO 4217 currency code (USD, EUR, GBP, etc.).
priceString?Raw price string.
strikePriceString?Original price before discount.
has_photoBoolWhether the listing has at least one photo.
photo_countIntNumber of photos.
photos[SellwildPhoto]Array of photo objects.
createdDateString?ISO 8601 creation timestamp.
videoUrlString?Video URL, if available.
shippableString?Shipping availability flag.
listingTypeString?Listing type identifier.
dataSourceIdString?Source identifier for multi-feed integrations.
userSellwildUser?Seller information.
distanceDouble?Distance from the user (when geo-sorted).

Computed properties:

PropertyTypeDescription
displayPriceString?Formatted price string, or null if price is zero or unparseable.
primaryPhotoSellwildPhoto?First photo, or null if no photos exist.

SellwildPhoto

FieldTypeDescription
urlStringFull-size image URL.
thumbUrlStringThumbnail image URL.
backgroundString?Background color hint (CSS hex).

SellwildUser

FieldTypeDescription
idStringUser identifier.
firstNameStringFirst name.
lastNameStringLast name.
usernameStringUsername.
membershipTypeStringMembership tier.
trustLevelStringTrust level.
has_photoStringWhether the user has a profile photo.
photos[SellwildPhoto]User profile photos.
isPhoneVerifiedBoolPhone verification status.

AdSize

Ad dimensions. See Ad Size Reference for the full table.

ValueDimensionsIAB Name
banner320x50 / "320x50"320 x 50Mobile Banner
mrec300x250 / "300x250"300 x 250Medium Rectangle
leaderboard728x90 / "728x90"728 x 90Leaderboard
halfPage300x600 / "300x600"300 x 600Half Page
wideSkyscraper160x600 / "160x600"160 x 600Wide Skyscraper

AdPlacement

Describes a single ad placement within the widget layout.

FieldTypeDescription
typeAdPlacementTypePlacement position: "banner_top", "banner_bottom", "inline", "interstitial".
zoneIdString?Zone identifier for the placement.
sizeAdSizeAd dimensions for this placement.

SellwildListingsResponse

Response from fetchListings.

FieldTypeDescription
listings[SellwildListing]Array of listing objects.
configMap<String, Any>Server-side widget configuration overrides.
widgetCacheVersionIdString?Cache version for conditional refresh.

Sellwild SDK Documentation