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
AdLoadedTime
Gets when the ad loaded now was loaded, in UTC, or null where none is.
DateTime? AdLoadedTime { get; }
Property Value
AdType
Gets the kind of ad the provider shows.
AdType AdType { get; }
Property Value
NetworkName
Gets the ad network's name.
string NetworkName { get; }
Property Value
Methods
LoadAd(IUiContext, CancellationToken)
Loads an ad, to show it later.
Task LoadAd(IUiContext uiContext, CancellationToken cancellationToken)
Parameters
uiContextIUiContextThe app's UI context.
cancellationTokenCancellationTokenThe 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
cancellationTokenwas canceled.
ShowAd(IUiContext, string?, CancellationToken)
Shows the ad loaded.
Task<ShowAdResult> ShowAd(IUiContext uiContext, string? customData, CancellationToken cancellationToken)
Parameters
uiContextIUiContextThe app's UI context.
customDatastringThe data the ad network passes to the server's check of a rewarded ad, or null.
cancellationTokenCancellationTokenThe 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
cancellationTokenwas canceled.