Table of Contents

Interface IAdProvider

Namespace
VpnHood.AppLib.Abstractions.Ads
Assembly
VpnHood.AppLib.Abstractions.dll

Represents one kind of ad of one ad network: it loads an ad, then shows it.

public interface IAdProvider : IDisposable
Inherited Members

Properties

AdLifeSpan

Gets how long a loaded ad may wait before it is shown.

TimeSpan AdLifeSpan { get; }

Property Value

TimeSpan

AdLoadedTime

Gets when the ad loaded now was loaded, in UTC, or null where none is.

DateTime? AdLoadedTime { get; }

Property Value

DateTime?

AdType

Gets the kind of ad the provider shows.

AdType AdType { get; }

Property Value

AdType

NetworkName

Gets the ad network's name.

string NetworkName { get; }

Property Value

string

Methods

LoadAd(IUiContext, CancellationToken)

Loads an ad, to show it later.

Task LoadAd(IUiContext uiContext, CancellationToken cancellationToken)

Parameters

uiContext IUiContext

The app's UI context.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that completes once an ad is loaded.

Exceptions

NoFillAdException

The network had no ad to fill the request.

LoadAdException

No ad could be loaded, as where the consent the network needs is missing.

AdException

The network's SDK could not start, as AdMob's with no ad adapter.

NotSupportedException

The network's SDK does not run on this Android version.

TimeoutException

The network's SDK did not start in time.

InvalidOperationException

The network's SDK did not start its initialization.

OperationCanceledException

cancellationToken was canceled.

ShowAd(IUiContext, string?, CancellationToken)

Shows the ad loaded.

Task<ShowAdResult> ShowAd(IUiContext uiContext, string? customData, CancellationToken cancellationToken)

Parameters

uiContext IUiContext

The app's UI context.

customData string

The data the ad network passes to the server's check of a rewarded ad, or null.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<ShowAdResult>

A task whose result is how the ad ended.

Exceptions

ShowAdException

The ad could not be shown.

RewardNotEarnedException

For a rewarded ad, the network did not confirm the reward in time after the ad closed.

OperationCanceledException

cancellationToken was canceled.