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.
CMP
Note: Once the CMP window pops up, it will remain open until the user makes a clear choice. Be sure to complete the execution of the CMP method before proceeding with any subsequent SDK operations.
using MiracleGamesAd;
using MiracleGamesAd.Models;
private async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
//Mode 1: Top banner mode
ApplicationManager.OpenCmp("YOUR_APP_KEY","YOUR_Secret_Key");
//Mode 2: Center popup mode
PopupCmpSettingOptions popupCmpSettingOptions = new PopupCmpSettingOptions();
popupCmpSettingOptions.IgnoreExpiredCheck = false; // false = do not pop up again after user's first choice. true = force pop up
var result = await ApplicationManager.OpenCmp("YOUR_APP_KEY","YOUR_Secret_Key", popupCmpSettingOptions);
if (result.ReturnValue)//CMP window displayed successfully
{
if (result.Tag is CmpResult cmpResult)
{
if (cmpResult.Success)//User made a selection
{
string str = cmpResult.Payload;//User selection result data
}
else//User did not make a selection
{
}
}
}
else
{
//CMP window display failed
}
}
SDK Initialization
using MiracleGamesAd;
using MiracleGamesAd.Models;
private async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
// Initialization interface call. Required parameters are applied for and created in the MG Ads backend.
var result = await ApplicationManager.Initialize("YOUR_APP_KEY", "YOUR_Secret_Key");
if (result.ReturnValue) // Initialization callback interface to check if initialization is complete.
{
}
}
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 promptly contact technical support.