Class InternalInAdProvider
Provides the app's own interstitial, which the UI shows and ends: the ad waits until the UI dismisses it (Dismiss(ShowAdResult)) or fails it (SetException(Exception)).
public class InternalInAdProvider : IAdProvider, IDisposable
- Inheritance
-
InternalInAdProvider
- Implements
- Inherited Members
Properties
AdLifeSpan
Gets how long a loaded ad may wait before it is shown.
public TimeSpan AdLifeSpan { get; }
Property Value
- TimeSpan
Five minutes.
AdLoadedTime
Gets when the ad loaded now was loaded, in UTC, or null where none is.
public DateTime? AdLoadedTime { get; }
Property Value
AdType
Gets the kind of ad the provider shows.
public AdType AdType { get; }
Property Value
IsWaitingForAd
Gets a value indicating whether an ad is showing and waits for the UI to end it.
public bool IsWaitingForAd { get; }
Property Value
NetworkName
Gets the ad network's name.
public string NetworkName { get; }
Property Value
- string
InternalAd.
Methods
Dismiss(ShowAdResult)
Ends the ad showing, if one is.
public void Dismiss(ShowAdResult result)
Parameters
resultShowAdResultHow the person ended it.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Remarks
An ad showing is canceled.
LoadAd(IUiContext, CancellationToken)
Loads an ad, to show it later.
public 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.
Remarks
It loads nothing and takes no cancel: it notes the time and returns at once.
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.
SetException(Exception)
Fails the ad showing, if one is.
public void SetException(Exception ex)
Parameters
exExceptionThe exception the ad's task ends with.
ShowAd(IUiContext, string?, CancellationToken)
Shows the ad loaded.
public 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.
Remarks
The task ends with the UI's answer (Dismiss(ShowAdResult)), with the exception the UI gives
(SetException(Exception)), or canceled, when cancellationToken is canceled or the provider
is disposed.
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.- OperationCanceledException
cancellationTokenwas canceled, or the provider was disposed.- Exception
The UI failed the ad with this exception (SetException(Exception)).