Advanced Settings - Vungle Windows SDK

First things first

This article covers the advanced settings of the Vungle Windows SDK. If you're not familiar with our Windows SDK, you'll want to check out our Getting Started Guide for Windows.

Contents

  1. playAdAsync configuration
  2. The adConfig object
  3. Showing the Close button
  4. Subscribing to events

playAdAsync configuration 

You can optionally customize the ads you play by providing an AdConfig object to PlayAdAsync.

using VungleSDK;

public sealed partial class SecondPage : Page
{
    ...
    async void PlayVungleAdAsync()
    {
        // the AdConfig object will only affect this ad play.
        await sdkInstance.PlayAdAsync(new AdConfig(){ 
            // set any configuration options you like. 
            // For a full description of available options, see the 'Configuration Options' section.
            Incentivized = true,
            SoundEnabled = false
        });
    }
} 

The adConfig object

These are the available properties in the AdConfig object instance:

MethodDefaultDescription
Orientation DisplayOrientations.
AutoRotate

Orientation.AutoRotate makes the ad autorotate with the device orientation.

Orientation.Portrait makes the ad play only in the portrait orientation

Orientation.Landscape makes the ad play only in the portrait orientation.

SoundEnabled true

Sets the starting sound state for the ad.

If true, the audio respects device volume and sound settings.

If false, video begins muted but user may modify.

BackButtonImmediatelyEnabled false

If true, allows the user to immediately exit an ad using the back button.

If false, the user cannot use the back button to exit the ad until the on-screen close button is shown.

Please note: this method is only supported on Windows Phone 8.1 & Windows 10. Windows 8.1 is not supported.

Incentivized false

Sets the incentivized mode: set this to true if you're using server-to-server callbacks for your rewarded ads.

If true, user will be prompted with a confirmation dialog when attempting to skip the ad.

If false, no confirmation is shown. Further instructions for setting up incentivized ads are here.

UserId null

Passes the unique user ID to your application to verify that this user should be rewarded for watching an incentivized ad.

This setting is not applicable if the ad is not incentivized.

IncentivizedDialogTitle null

Sets the title of the confirmation dialog when skipping an incentivized ad. 

This setting is not applicable if the ad is not incentivized.

IncentivizedDialogBody "Are you sure you want to skip this ad? If you do, you might not get your reward"

Sets the body of the confirmation dialog when skipping an incentivized ad.

This setting is not applicable if the ad is not incentivized.

IncentivizedDialogCloseButton "Close"

Sets the 'cancel' button text of the confirmation dialog when skipping an incentivized ad. 

This setting is not applicable if the ad is not incentivized.

IncentivizedDialogContinueButton "Continue"

Sets the 'keep watching' button text of the confirmation dialog when skipping an incentivized ad. 

This setting is not applicable if the ad is not incentivized.

Extra[0..7] null You can use this to track attributes such as age group, gender, etc.
Placement null Sets an optional ad placement name for enhanced reporting on the dashboard.

Showing the Close button

To control whether a user has the option to close out of an ad, use the forced view options in your app's advanced settings on the Vungle Dashboard.

Subscribing to events

The Publisher SDK raises several events that you can handle programmatically.

UI Thread Note

The event listeners are executed on a background thread, so any UI interaction or updates resulting from an event listener must be passed to the main UI thread before executing. Here is one way to do it:

await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                new DispatchedHandler(() => 
                {
                    // this block will be executed in the UI thread
                }
));

VungleAd events

using VungleSDK;

public sealed partial class MainPage : Page
{
    VungleAd sdkInstance;
    public MainPage()
    {
        InitializeComponent();

        var appId = "your Vungle App ID";
        sdkInstance = AdFactory.GetInstance(appId);

        sdkInstance.OnAdPlayableChanged += Sdk_OnAdPlayableChanged;
        sdkInstance.OnAdStart += VungleAd_OnAdStart;
        sdkInstance.OnAdEnd += VungleAd_OnAdEnd;
        sdkInstance.OnVideoView += VungleAd_OnVideoView;
        sdkInstance.Diagnostic += VungleAd_Diagnostic;
    }

    private void Sdk_OnAdPlayableChanged(object sender, AdPlayableEventArgs e)
    {
        // This will get called with an parameter e.AdPlayable is true
        // when the SDK has an ad ready to be displayed.
        // Also it will get called with an parameter e.AdPlayable is false
        // when for some reason, there's no ad available.
    }

    private void VungleAd_OnAdStart(object sender, AdEventArgs e)
    {
        // Called before playing an ad
    }

    private void VungleAd_OnAdEnd(object sender, AdEndEventArgs e)
    {
        // Called when the user leaves the ad and control is returned to your application.
        // e.CallToActionClicked is true when the user clicked a Download button 
    }

    private void VungleAd_OnVideoView(object sender, AdViewEventArgs e)
    {
        // Called each time an ad completes. e.IsCompletedView is true if at least  
        // 80% of the video was watched, which constitutes a completed view.  
        // e.WatchedDuration is a longest video view time (if the user replayed the video).
        // e.VideoDuration is a total video time.
    }

    private void VungleAd_Diagnostic(object sender, DiagnosticLogEvent e)
    {
        // Called when sdk want to send some logs.
        // e.Message contains log message
        // e.Level indicates log Level (Trace, Debug, Info, Warn, Error, Fatal)
    }   
}
Have more questions? Submit a request

Comments