Skip to main content

SDK Initialization

Introduction

Before integrating the MG Ads SDK, it is necessary to first perform SDK initialization and CMP calls. Only after initialization is completed can the full functionality of this SDK be used in coordination with the backend system. The SDK initialization should be performed immediately upon entering the game.

SDK Initialization


MainPage :: MainPage()
{
InitializeComponent();
try
{
MiracleGamesAd::ApplicationManager::OpenCmp("YOUR_APP_KEY","YOUR_Secret_Key");//CMP
Loaded += ref new RoutedEventHandler([this](Object^, RoutedEventArgs^)
{
concurrency::create_task(MiracleGamesAd::ApplicationManager::Initialize("YOUR_APP_KEY", "YOUR_Secret_Key")).then([](MiracleGamesAd::Services::Core::Common::AsyncProcessResult^ result) // Call the initialization interface. The required parameters are created by applying in the MG advertising backend.
{
if (!result->ReturnValue) // Initialization callback interface to check if initialization is complete.
return;

});
});
}
catch (...){} // Add exception handling mechanism to prevent game crashes.
}

Possible Errors if Initialization Fails

● Network failure, no proper network support

  ● UWP applications do not support VPN, and VPN software is enabled on the local machine.

  ● Incorrect AppId, please log in to the developer backend to check application settings.

  ● Server issues, please check the error information in the result and contact technical support promptly.