Banner Adverts

Show banner ads from AdDuplex. Additional setup is required once you have built the Universal Windows Platform solution from Unity - see the setup section at the bottom of the page

Reference the library

C#
using CI.WSANative.Advertising;

Initialise

Initialises the specified ad network - this should be called once for each ad network you intend to use

C#
WSANativeBannerAd.Initialise(WSABannerAdType.AdDuplex, "AppId", "AdUnit or placement id");

Create a banner ad

WSANativeBannerAd.AdRefreshed is raised each time a new ad is shown

The width and height should be equal to or greater than the size of the ad - ad sizes vary by provider

C#
WSANativeBannerAd.CreatAd(WSABannerAdType.AdDuplex, 728, 90, WSAAdVerticalPlacement.Top, WSAAdHorizontalPlacement.Centre);

Hide or show the banner ad

C#
WSANativeBannerAd.SetVisibility(WSABannerAdType.AdDuplex, false);

Reconfigure the banner ad

The width and height should be equal to or greater than the size of the ad - ad sizes vary by provider

C#
WSANativeBannerAd.ReconfigureAd(WSABannerAdType.AdDuplex, 728, 90, WSAAdVerticalPlacement.Bottom, WSAAdHorizontalPlacement.Right);

Destroy the banner ad

C#
WSANativeBannerAd.DestroyAd(WSABannerAdType.AdDuplex);

Events

Listen to these events for info about the ads lifecycle

C#
WSANativeBannerAd.AdRefreshed
C#
WSANativeBannerAd.ErrorOccurred

Setup

Perform the following steps in the uwp solution

  1. Open the solution and add a reference to the ad sdks you wish to use (AdDuplex SDK)
  2. Download this file and add it to the project which has the same name as your game. Make sure it is in the same folder as MainPage.xaml.cpp
  3. Open the file you just added to the project and you'll see some #defines at the top with the names of ad networks. Replace the 0 with a 1 next to the ones you plan to use
  4. Open MainPage.xaml.cpp and add the following includes
C#
#define GENERATED_PROJECT 1 #include "WSAAdvertisingBridge.h" #include "BannerAdManager.h"
  1. At the bottom of the MainPage.xaml.cpp constructor add the following line
C#
BannerAdManager::Initialise(m_DXSwapChainPanel);
  1. Open the apps manifest file and add the internet client capability