How do I show an ad in C++?

Hey you all,

I found this in the docs: Show Ad Banner | Unreal Engine Documentation

However, this is for blueprint. How do I call this in C++?

Cheers,
Lukas Wagner

This is the code for the kismet ShowAdbanner function:

void UKismetSystemLibrary::ShowAdBanner(bool bShowOnBottomOfScreen)
    {
    	if (IAdvertisingProvider* Provider = FAdvertising::Get().GetDefaultProvider())
    	{
    		Provider->ShowAdBanner(bShowOnBottomOfScreen);
    	}
    }
    
    void UKismetSystemLibrary::HideAdBanner()
    {
    	if (IAdvertisingProvider* Provider = FAdvertising::Get().GetDefaultProvider())
    	{
    		Provider->HideAdBanner();
    	}
    }

The providers are: IAdvertisingProvider | Unreal Engine Documentation

Seems there are already implimentations for android and IOS:

  • …\Epic\Games\4.8\Engine\Source\Runtime\Advertising\Android
  • …\EpicGames\4.8\Engine\Source\Runtime\Advertising\IOS