Integrate Vungle SDK for Win32 or WinUI 3

Use this article to integrate the Vungle SDK for these Windows platforms:

  • Win32 (Native Desktop, C++)
  • WinUI 3

Requirements

  • Vungle SDK v.7.0.0 for Win32 and WinUI 3 both support Windows v.10 and v.11.
  • Microsoft WebView2 Runtime: Vungle SDK uses the new Microsoft Edge WebView2 browser control to display our ads. WebView2 depends on the Microsoft Edge WebView2 Runtime to function at runtime; without it, your library will fail to create or display the webview even if everything is linked correctly. The installer for your application must install the WebView2 Runtime. Of the three options discussed below, we recommend the Evergreen Bootstrapper. You can learn more about these options in the Microsoft Edge Developer documentation.
    • Evergreen Bootstrapper (Recommended): The Evergreen Bootstrapper is a small installer (~2 MB) that downloads and installs the latest WebView2 runtime during setup. We recommend this option because it auto-updates, is lightweight, and is easy to integrate into existing MSI/EXE installers.
    • Evergreen Standalone Installer: The full installer (~120 MB) is suitable for offline environments because it doesn’t require internet.
    • Fixed Version Distribution: Fixed Version distribution bundles a known-good version of WebView2 inside the installer or app folder and gives you full control over runtime version and updates. However, it does have a larger footprint and requires more maintenance.

Step 1. Add the Vungle SDK Into Your Project

  1. Use NuGet package manager inside Visual Studio to install the Vungle SDK.
    • Win32 (Native Desktop, C++):

      IntegrateSDKforWindowsNativeNuget.png
       
    • WinUI 3:

      NugetWinUI3.png
       
  2. For C++, add the following includes to your .cpp file. 

    Note: These C++ includes do not apply to WinUI 3 or UWP, both of which use C# code.
     

    Win32 (Native Desktop, C++)
    #include <LiftoffAds.h>
    #include <EventArguments\AdLoadCallback.h>
    #include <EventArguments\InitializationCallback.h>
    #include <EventArguments\AdLoadEventArgs.h>
    #include <EventArguments\AdPlayCallback.h>
    

Step 2. Initialize the SDK

Win32 (Native Desktop, C++)WinUI 3 (C#)
void OnLiftoffInitializationSuccess(const InitializationSuccessEventArgs& args) {
    std::cout << "Initialization succeeded!" << std::endl;
}

void OnLiftoffInitializationFailure(const InitializationFailureEventArgs& args) {
    std::cout << "Initialization Failed!" << std::endl;
}

LiftoffSdkConfig config;
InitializationCallback initCallback;

std::string appIDStr = "<your app id from Vungle Dashboard>";

initCallback.OnInitializationFailure = OnLiftoffInitializationFailure;
initCallback.OnInitializationSuccess = OnLiftoffInitializationSuccess;

auto futureInstance2 = LiftoffAds::InitializeAsync(appIDStr, config, hWnd, initCallback);

g_sdkInstance = futureInstance2.get();
  
  // Create callbacks for initialization success or failure
  void OnLiftoffInitializationSuccess(const InitializationSuccessEventArgs& args) {
	try
	{
		std::cout <><"initialization><><><"error during="during" couldn="couldn" t="t" get="get"><><><><><"initialization><><><><><><><><><>

Step 3. Add Code to Load and Play an Ad

Load an Ad

Win32 (Native Desktop, C++)WinUI 3 (C#)
/// <summary>
/// This callback gets called when an ad successfully loads.
/// </summary>
void OnAdLoadSuccess(AdLoadEventArgs args) {
    std::cout << "Ad Load Success! " << "Bundle Count: " << args.BundleCount << std::endl;
}

/// <summary>
/// This callback gets called when an ad fails to load.
/// </summary>
void OnAdLoadFailure(AdLoadEventArgs args) {
    std::cout << "Ad Load Failure! " << args.ErrorMessage << std::endl;
}

AdLoadCallback callback;
callback.OnAdLoadFailure = OnAdLoadFailure;
callback.OnAdLoadSuccess = OnAdLoadSuccess;

// Load the ad using the selected placement name
g_sdkInstance->LoadAd(
"<your placement name from Vungle Dashboard>",
callback);

Play an Ad

Win32 (Native Desktop, C++)WinUI 3 (C#)
/// <summary>
/// Handles the start of an advertisement by logging its placement and event ID.
/// </summary>
/// <param name="args">An AdPlayEventArgs object containing information about the ad placement and event ID.</param>
void OnAdStart(AdPlayEventArgs args) {
    std::cout << "Ad started for placement: " << args.Placement << " with event id: " << args.EventID << std::endl;
}

/// <summary>
/// Handles the event triggered when an advertisement finishes playing.
/// </summary>
/// <param name="args">The event arguments containing information about the ad playback, 
/// including the placement name.
/// </param>
void OnAdEnd(AdPlayEventArgs args) {
    std::cout << "Ad ended for placement: " << args.Placement << std::endl;
}

/// <summary>
/// Handles the event when an advertisement fails to play.
/// </summary>
/// <param name="args">The event arguments containing information about the ad play failure, including the placement identifier.</param>
void OnAdPlayFailure(AdPlayEventArgs args) {
    std::cout << "Ad Play Failure for placement: " << args.Placement << std::endl;
}

/// <summary>
/// Handles the event when a rewarded advertisement has been successfully played.
/// A "rewarded ad" is one where the user should receive some in-app reward for watching most or all of the ad.
/// </summary>
/// <param name="args"></param>
void OnAdPlayRewarded(AdPlayEventArgs args) {
    std::cout << "Ad Play Rewarded for placement: " << args.Placement << std::endl;
}

/// <summary>
/// Handles the event when an advertisement is clicked by the user.
/// </summary>
/// <param name="args"></param>
void OnAdPlayClick(AdPlayEventArgs args) {
    std::cout << "Ad Play Clicked for placement: " << args.Placement << std::endl;
}

AdPlayCallback playCallback;

playCallback.OnAdStart = OnAdStart;
playCallback.OnAdEnd = OnAdEnd;
playCallback.OnAdPlayFailure = OnAdPlayFailure;
playCallback.OnAdPlayRewarded = OnAdPlayRewarded;
playCallback.OnAdPlayClick = OnAdPlayClick;

AdConfig config = AdConfig();

g_sdkInstance->PlayAd(
"<your placement id from Vungle Dashboard>",
       playCallback,
       config);

Step 4. Configure Advanced Settings

Follow these advanced settings to fine-tune your app's integration with additional configuration options, such as GDPR, CCPA implementation, and many other settings.

GDPR

As of May 25, 2019, the General Data Protection Regulation (GDPR) is enforced in the European Union. To comply with GDPR, developers have the following options.

  • Option 1 (recommended): Allow Vungle to handle the requirements. Vungle will display a consent dialog before playing an ad for a European user, and will remember the user’s consent or rejection for subsequent ads.
  • Option 2: Publisher controls the GDPR consent process at the user level, then communicates the user’s choice to Vungle. To do this, developers can collect the user’s consent using their own mechanism, and then use Vungle APIs to update or query the user’s consent status. Refer to the sample code below for details.

The SetGdprConsentStatus method (recommended in Option 2) takes the user's consent status and the consent message version as its parameters.

Use the following example to add similar code for setting GDPR status:

Win32 (Native Desktop, C++)WinUI 3 (C#)
// use the following line of code if you want to opt in to GDPR 
// this will result in higher revenue
GdprConsentStatus status = GdprConsentStatus::ConsentAccepted;
// Use the following line of code if you want to opt out of GDPR
// This will result in lower revenue, but you must do it if GDPR laws are relevent 
// to your user.
status = GdprConsentStatus::ConsentDenied; break;   // Opted Out

std::string versionStr = "1.0"  // you can update this with your own version

LiftoffAds::SetGdprConsentStatus(status, versionStr);

Use the following code to get the current GDPR status:

Win32 (Native Desktop, C++)WinUI 3 (C#)
GdprConsentStatus status = LiftoffAds::GetGdprConsentStatus();
LPCWSTR statusText = L"Unknown";
switch (status) {
    case GdprConsentStatus::ConsentAccepted:
        statusText = L"Opted In";
        break;
    case GdprConsentStatus::ConsentDenied:
        statusText = L"Opted Out";
        break;
}

COPPA

Generally speaking, the Children’s Online Privacy Protection Act (COPPA) regulates the collection, use, and disclosure of personal information for children under the age of 13 by certain websites and online services (including mobile apps). Compliance with COPPA is a legal issue and we suggest you seek the advice of an attorney in determining compliance. Additionally, for more information on COPPA, please refer to the Federal Trade Commission's COPPA FAQ.

Liftoff has tools to assist publishers with COPPA compliance. In addition to use of settings on the Liftoff Monetize Dashboard, Liftoff offers features within the Vungle SDK using the COPPA API.

COPPA Compliance at the App Level

Liftoff provides tooling in the Monetize Dashboard to indicate COPPA compliance for each app. When defining your app in the Liftoff Monetize Dashboard, you must indicate to Liftoff whether your app is directed toward children under age 13. Depending on your setting, Liftoff will globally treat all traffic for the app as subject to COPPA or not. If you indicate that your app is not directed toward children under 13, COPPA settings will not apply at the app level, and can then be indicated at a more granular level (see COPPA Compliance at the Device Level).

COPPA Compliance at the Device Level

Starting with SDK v.6.11 early access, Vungle provides an optional method for you to indicate at the device level whether the user within the given mobile app is under or over the age of 13 by using the SDK COPPA API. The SDK COPPA API is most appropriate in cases of apps that legally can implement an age screen or age gate in accordance with COPPA, rather than treating all users as under 13. If you believe your app as a whole is primarily directed to children under the age of 13 as set forth in COPPA and related guidance, the COPPA Dashboard settings are more appropriate for you.

Recommendations for Using Vungle's COPPA Compliance Tools

  • Pursuant to the Vungle SDK License and Publisher Terms, it is the publisher’s responsibility to ensure compliance with applicable laws, including COPPA. Vungle is not liable for COPPA violations resulting from incorrect settings communicated via the SDK COPPA API. Consider the following recommendations to help you ensure COPPA compliance.
  • Use the SDK COPPA API for mixed-audience apps. Use the SDK COPPA API if:
    • You have confirmed you are a “mixed-audience app” under COPPA
    • You have implemented an age gate or age screen
    • You have stated that for your app “COPPA settings will NOT apply” in the Publisher Dashboard (otherwise, a COPPA-compliant setting in your Dashboard will override any API settings to the contrary)
  • Use the Dashboard for apps directed towards children under 13: In cases where it is clear that your app is primarily directed to children under the age of 13, use the COPPA settings section in the Publisher Dashboard instead of the SDK COPPA API.
  • Conflicting settings between API and Dashboard: As noted above, you can establish COPPA settings at the app level (but not at the user level) on the Publisher Dashboard, and at the device/user level by using the SDK COPPA API. Under the current release of SDK COPPA API functionality, in the event of a conflict between the settings in Publisher Dashboard and those passed via the SDK COPPA API, the COPPA-compliant setting takes precedence.

For example, if your app setting on the Publisher Dashboard is COPPA-compliant, and that same app also enables use of the SDK COPPA API and identifies a given user as over 13, Vungle will defer to the Dashboard setting, which states that all the users in this app are protected by COPPA regulations. If, on the other hand, your app setting on the Publisher Dashboard states that your app is not directed toward users under the age of 13, but a call to the SDK COPPA API identifies a given user as under age 13, Vungle will override the dashboard setting and treat that user as being protected by COPPA regulations.

COPPA API

Use the following example to add similar code for setting COPPA status:

Win32 (Native Desktop, C++)WinUI 3 (C#)
BOOL coppaStatus = TRUE; // opted in to privacy; set to FALSE to opt out
LiftoffAds::SetCoppaStatus(coppaStatus);

Use the following example to add similar code to determine the current COPPA status. Note that the status defaults to ‘false’ if you don’t set it.

Win32 (Native Desktop, C++)WinUI 3 (C#)
BOOL coppaStatus = LiftoffAds::GetCoppaStatus();

CCPA

As of July 1, 2020, California Consumer Privacy Act (CCPA) is enforced.

The AdFactory.UpdateCcpaStatus() method takes the user's consent status to specify whether the user has OptedIn or OptedOut and AdFactory.GetCcpaStatus() method returns current CCPA status for the user.

In accordance with CCPA, the consent status is opted in by default unless UpdateCcpaStatus() has been explicitly called to set it as opted out.

Use the following code to set the CCPA status:

Win32 (Native Desktop, C++)WinUI 3 (C#)
// use this line if you want to give the user more privacy
CcpaConsentStatus status = CcpaConsentStatus::OptedIn 
// or, use this line if you want to opt the user out of privacy
CcpaConsentStatus status = CcpaConsentStatus::OptedOut;
LiftoffAds::SetCcpaStatus(status);

Use the following code to get CCPA status:

Win32 (Native Desktop, C++)WinUI 3 (C#)
CcpaConsentStatus status = LiftoffAds::GetCcpaStatus();
LPCWSTR statusText = L"Unknown";
switch (status) {
case CcpaConsentStatus::OptedIn: // privacy is on
    statusText = L"Opted In";
    break;
case CcpaConsentStatus::OptedOut: // privacy is off
    statusText = L"Opted Out";
    break;
}

Expert-Level Setting: Enable Mediation

Enable mediation to monetize your Windows app through in-app bidding with Vungle SDK. In addition to the client-side code below, your server team must work with our server team to set up communication between our mediation servers. Contact us for more information.

  1. Call the SDK’s GetMediationSuperToken method to get a SuperToken from the SDK.

    Win32 (Native Desktop, C++)WinUI 3 (C#)
    std::string placementID = "<placement name>";
    std::string superToken = m_sdk->GetMediationSuperToken(placementID);
    
    if (superToken.empty()) {
        MessageBox(hWnd, L"Failed to get super token from SDK.", L"Get Super Token", MB_OK | MB_ICONERROR);
        return;
    }
  2. Send this SuperToken to your server; your server will then send this SuperToken to the Vungle server.
  3. The Vungle server then decides whether to bid on this opportunity, and if yes, how much to bid.

    • If Vungle does decide to bid, it will return a non-blank token; otherwise, it will return an empty string.
    • If the Vungle server decides to bid on this opportunity, it will return Ad Markup. You will later need a section of this ad markup to send as a parameter to LoadMediatedAd and PlayMediatedAd.
    Ad Markup (JSON)
    {
        "id": "123456",
        "seatbid": [{
                "bid": [{
                        "id": "68e6cdfc496a5c6f19f3df9a",
                        "impid": "234567",
                        "price": 50.001,
                        "nurl": "https://events.ads.vungle.com/api/win?settlement_price=${AUCTION_PRICE}\u0026ext=eyJpZCI6IjY4ZTZjZGZjNDk2YTVjNmYxOWYzZGY5YSIsImltcF9pZCI6IjEiLCJuYW1lIjoibWF4IiwicHJpY2UiOjUwLjAwMSwiYmZsYXRfcHJpY2UiOjUwLjAwMSwicHJfbWwiOjEsImJpZCI6IjY4ZTZjZGZjNDk2YTVjNmYxOWYzZGY5YSIsImludGVybmFsIjp0cnVlLCJvcmRpbmFsIjoxLCJ0Ijp0cnVlLCJzZGtfYnVybCI6dHJ1ZSwibSI6MSwiYXBwaWQiOiI1OTc2NmVkM2NjOWI5OGUzNzEwMDBjYmMiLCJwcmlkIjoiVEVTVF9CSURESU5HX1BMQUNFTUVOVC01MjE3MjkyIiwibiI6dHJ1ZSwidnhfcHJpY2UiOjEwMS4wMDEsInZ4X3NlY29uZF9wcmljZSI6MTAwLjAwMSwiY2NfaXNvMiI6IlVTIiwiaXNfczJzIjpmYWxzZSwic3YiOiI3LjAuMC1xYTE2Iiwib3MiOiJ3aW5kb3dzIiwiZGV2X2lkIjoiNWEwYzFlNTk0MDIzZjBlYTcwNjdmN2IzZTk2Y2EyZmQiLCJkZXZfaWRfc291cmNlIjoiSUZBIiwicnRiX2lkIjoiNjRkYjI5NThiMTNiYjJjODcwYmE5NzI0In0=\u0026second_highest_price=${AUCTION_MINIMUM_BID_TO_WIN}",
                        "burl": "https://events.ads.vungle.com/api/bill?settlement_price=${AUCTION_PRICE}\u0026ext=eyJpZCI6IjY4ZTZjZGZjNDk2YTVjNmYxOWYzZGY5YSIsImltcF9pZCI6IjEiLCJuYW1lIjoibWF4IiwicHJpY2UiOjUwLjAwMSwiYmZsYXRfcHJpY2UiOjUwLjAwMSwicHJfbWwiOjEsImJpZCI6IjY4ZTZjZGZjNDk2YTVjNmYxOWYzZGY5YSIsImludGVybmFsIjp0cnVlLCJvcmRpbmFsIjoxLCJ0Ijp0cnVlLCJzZGtfYnVybCI6dHJ1ZSwibSI6MSwiYXBwaWQiOiI1OTc2NmVkM2NjOWI5OGUzNzEwMDBjYmMiLCJwcmlkIjoiVEVTVF9CSURESU5HX1BMQUNFTUVOVC01MjE3MjkyIiwibiI6dHJ1ZSwidnhfcHJpY2UiOjEwMS4wMDEsInZ4X3NlY29uZF9wcmljZSI6MTAwLjAwMSwiY2NfaXNvMiI6IlVTIiwiaXNfczJzIjpmYWxzZSwic3YiOiI3LjAuMC1xYTE2Iiwib3MiOiJ3aW5kb3dzIiwiZGV2X2lkIjoiNWEwYzFlNTk0MDIzZjBlYTcwNjdmN2IzZTk2Y2EyZmQiLCJkZXZfaWRfc291cmNlIjoiSUZBIiwicnRiX2lkIjoiNjRkYjI5NThiMTNiYjJjODcwYmE5NzI0In0=",
                        "lurl": "https://events.ads.vungle.com/api/loss?settlement_price=${AUCTION_PRICE}\u0026loss_reason=${AUCTION_LOSS}\u0026auction_min_to_win=${AUCTION_MIN_TO_WIN}\u0026ext=eyJpZCI6IjY4ZTZjZGZjNDk2YTVjNmYxOWYzZGY5YSIsImltcF9pZCI6IjEiLCJuYW1lIjoibWF4IiwicHJpY2UiOjUwLjAwMSwiYmZsYXRfcHJpY2UiOjUwLjAwMSwicHJfbWwiOjEsImJpZCI6IjY4ZTZjZGZjNDk2YTVjNmYxOWYzZGY5YSIsImludGVybmFsIjp0cnVlLCJvcmRpbmFsIjoxLCJ0Ijp0cnVlLCJzZGtfYnVybCI6dHJ1ZSwibSI6MSwiYXBwaWQiOiI1OTc2NmVkM2NjOWI5OGUzNzEwMDBjYmMiLCJwcmlkIjoiVEVTVF9CSURESU5HX1BMQUNFTUVOVC01MjE3MjkyIiwibiI6dHJ1ZSwidnhfcHJpY2UiOjEwMS4wMDEsInZ4X3NlY29uZF9wcmljZSI6MTAwLjAwMSwiY2NfaXNvMiI6IlVTIiwiaXNfczJzIjpmYWxzZSwic3YiOiI3LjAuMC1xYTE2Iiwib3MiOiJ3aW5kb3dzIiwiZGV2X2lkIjoiNWEwYzFlNTk0MDIzZjBlYTcwNjdmN2IzZTk2Y2EyZmQiLCJkZXZfaWRfc291cmNlIjoiSUZBIiwicnRiX2lkIjoiNjRkYjI5NThiMTNiYjJjODcwYmE5NzI0In0=",
                        "adm": "{\"version\":2,\"adunit\":\"H4sIAAAJbogA/+x8/W/iOtb/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A=\",\"impression\":[]}",
                        "adomain": ["domain1.com"],
                        "bundle": "9P5LPK6CRX64",
                        "cid": "kraken_online_feeder_cid",
                        "crid": "685c7bfa7ae70dc10f9d151e"
                    }
                ],
                "seat": "vungle"
            }
        ],
        "bidid": "68e6cdfc496a5c6f19f3df9a",
        "cur": "USD",
        "ext": {
            "test": 1,
            "debug": {}
        }
    }

    Note the section labelled ”adm”. This ”adm” section contains the string you must send to LoadMediatedAd and PlayMediatedAd

  4. Using a JSON library, create a variable from the above ad markup, using the following as an example:

    Win32 (Native Desktop, C++)WinUI 3 (C#)
    std::string adm = "{\"version\":2,\"adunit\":\"H4sIAAAJbogA/+x8/W/iOtb/v1Jld6XvVyrUCSQhSOiKhkBTXkKT8LpzZTmOA4a8TWKgdG7/90cOtIXOzN7uPndGz6z4qcR2bZ/POZ9zTuzYXwTk50L9n1+ENESYRCRmMCMByUiMCaS+UBdcw3HhrdlqmYMOHPaautE3Bm5JlkRV0iThWkA+jFC23qRC/YtQ/ItSIwr2A1zVFCRjJRC1oOIHGhKuBYyiFNFFXLSqVZAkahgEQPZVIgIVKzXZ+0OpyVj1AqQiogIfiyDQfFEWyR8+YijHtFRCm4WowmRJIHlMwyQjMGdoQeNFqfTlk5CvUVyKEp+En4R6vAnD51Ip32BM8rxUigjNGcn++BdzRGl6EP3v4O9fPh0fPwn1T4JSEzVMJBl4KtKqQMSSrAWYqJ+E608C2ZKYma1jw2/3/kl4Fq4F8pjSbC/URVXWNKWiqMq1wFLEhPoXAYcUr0dZKNT/KSwZS/P6zQ1K0zJK0zwI9yQr4yS60YZyb9hVdHuqVH9Lqd/YbuJFSCCN2acNAJKCAphTRqjfkFVN1apADjwQeGqAFQIAAEg6tMMNSQaqJMMdjeFkAqGjQzPOGQpDqFt9aA1f+8NJzmABa0MfmufFWxRuSAOU1fNivMm4Je0bI6f1VgOp3/ie8l9bIb+h96GoSeBRBDUAtxKoQWMAE1gB+f/bSv//pOWhw28bzWuzfONVGtruyY9xFix3vnRa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FherfZ0P8HvmkjXhYpP9/Wo2EXezSRgfUtJZ1WoNlv2VIc+ebqN+a7weSKPHfstfDVYLcRbvJKs1Xg2k+2jm+su5i3fzTv+x35nJ85Yh9ifj2rzTBrPpYIUcwGbTcdx3/cCTluFUGldx53GLo3GAK/ZyLoWb+R4wIu4oltjSoyLzJDv02jtqRbLodR61niM++ZPBaj4dPPUckc0n4ZPfGe+D1qw6d+ereWe+GrTW0swdrwbR7NGazJ7mnZk8c+61l/UZmHgrgo9QHBbUNd+rBqpXkyStimXRR57Al5k/b2hGcphTn3BfSePF6yIS8p1ih+0t22Q0IjlDUXq8bVFWqqry/Pz78/8AAAD//wMABDi2AvpSAAA=\",\"impression\":[]}"
  5. Call LoadMediatedAd with the placement name, the text from the adm section, and some optional success and failure callbacks:

    Win32 (Native Desktop, C++)WinUI 3 (C#)
    AdLoadCallback callbacks;
    callbacks.OnAdLoadFailure = OnAdLoadFailure;
    callbacks.OnAdLoadSuccess = OnAdLoadSuccess;
    
    // Call into the SDK to load the mediated ad
    bool loaded = m_sdk->LoadMediatedAd(placementID, callbacks, adm);

    Your OnAdLoadSuccess callback will notify you when the ad is ready to play.

  6. Call PlayMediatedAd with and AdConfig, the placement name, the ad markup section, and callbacks to play the ad:

    Win32 (Native Desktop, C++)WinUI 3 (C#)
    AdPlayCallback playCallbacks;
    playCallbacks.OnAdStart = OnAdStart;
    playCallbacks.OnAdEnd = OnAdEnd;
    playCallbacks.OnAdPlayFailure = OnAdPlayFailure;
    playCallbacks.OnAdPlayRewarded = OnAdPlayRewarded;
    playCallbacks.OnAdPlayClick = OnAdPlayClick;
    
    // Optionally, you can modify AdConfig to change the hWnd
    // window where the ad will play, and also "Incentivized" text
    // for any "Rewarded" ads you are playing
    AdConfig config;
    
    // Call SDK: Play a mediated ad (header-bidding) synchronously
    LiftoffAdPlayInfo info = g_sdkInstance->PlayMediatedAd(config, placementID, playCallbacks, adm);

    Refer to the following example of the AdConfig:

    Win32 (Native Desktop, C++)WinUI 3 (C#)
    class AdConfig {
    public:
        // Gets or sets the title of the confirmation dialog when skipping an incentivized ad.
        std::string IncentivizedDialogTitleText = "";
        // Gets or sets the body of the confirmation dialog when skipping an incentivized ad.
        std::string IncentivizedDialogBodyText = "";
        // Gets or sets the 'cancel button' text of the confirmation dialog when skipping an incentivized ad.
        std::string IncentivizedDialogCloseButtonText = "";
        // Gets or sets the 'continue button' text of the confirmation dialog when skipping an incentivized ad.
        std::string IncentivizedDialogContinueButtonText = "";
        // Use this to override which window the ad is displayed in.
        // If this is not set, the SDK will use the main window provided during initialization.
        HWND hPublisherWnd = nullptr;
    };

Questions?

Need further assistance, feel free to reach out to us, we’re here to help!

Was this article helpful?