Skip to main content

SDK Initialization

Introduction

Before integrating the MG Ads SDK, the SDK must be initialized first. Only after successful initialization can all the functions of this SDK be used in conjunction with the backend system. SDK initialization should be performed immediately upon entering the game.

SDK Initialization

private async void Form1_Load(object sender, EventArgs e)
{
string message;

ApplicationManager.SetAppId(YourAppId, YourSecretKey);
ApplicationManager.OpenCmp(this);
var result = await ApplicationManager.Initialize();
if (result.ReturnValue)
{
//Initialization successful.
message = "Initialization complete";

//Splash Screen Ad
AdvertManager.ShowAd(this, "768338453d614f3aad85eea7e3916e7e", AdType.FullScreen);

//Exit Screen Ad; Step1. After successful initialization, load exit screen ad resources
AdvertManager.SetupExitAd("7cdc7614b69c4118933e2067e6e14d01");
}
else
{
message = "Initialization failed";
}

this.Invoke(new Action(() =>
{
textBox1.Text = message;
}));
}

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 check the application settings in the developer backend

● Server issues, please check the error message in the result and contact technical support in a timely manner