CMP与SDK初始化
简介
在调用MG Ads SDK的广告功能之前,首先需要进行SDK的初始化和CMP(Consent Mode Platform)调用,完成后,才可以配合后台系统使用本SDK的全部功能,在进入游戏后立即进行SDK初始化和CMP的调用。
CMP
注意:CMP 窗口弹出后,在用户未做出明确选择前,窗口将保持打开状态。请务必在 CMP 方法执行完毕,再执行其他 SDK 的后续操作。
using MiracleGamesAd;
using MiracleGamesAd.Models;
private async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
PopupCmpSettingOptions popupCmpSettingOptions = new PopupCmpSettingOptions();
popupCmpSettingOptions.IgnoreExpiredCheck = false; //false=用户首次选择后则不再弹出。true=强制弹出
var result = await ApplicationManager.OpenCmp("YOUR_APP_KEY","YOUR_Secret_Key", popupCmpSettingOptions);
if (result.ReturnValue)//CMP窗口展示成功
{
if (result.Tag is CmpResult cmpResult)
{
if (cmpResult.Success)//用户做出了选择
{
string str = cmpResult.Payload;//用户的选择结果数据
}
else//用户未作出选择
{
}
}
}
else
{
//CMP窗口展示失败
}
}
SDK初始化
using MiracleGamesAd;
using MiracleGamesAd.Models;
private async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
//CMP接口
ApplicationManager.OpenCmp("YOUR_APP_KEY","YOUR_Secret_Key");
//初始化接口调用,所需参数在MG广告后台申请创建
var result = await ApplicationManager.Initialize("YOUR_APP_KEY","YOUR_Secret_Key");
if (result.ReturnValue)//初始化回调接口,检测是否初始化完成。
{
}
}
没有初始化成功的错误可能如下
● 网络故障,没有正确的网络支持
● UWP应用不支持VPN,本机开启了VPN软件
● AppId错误,请登录开发者后台检查应用设置
● 服务器问题,请检查result的错误信息,及时联系技术支持