Login MG advertising platform websiteto register a developer account.fter the registration , create an application, add advertising space information (advertising space ID will be generated after adding , which will be used later when embedding advertising), and then generate an official channel Publisher ID (embed in advertising later) , and then download advertising SDK compressed file, which includes SDK file and development documentation, you can embed the advertising in your app according to the documentation. After embed successfuly , the app can be updated to Microsoft developer background for review. After the review , you can promote the app to get advertising revenue.
Login MG Advertising Platform website to register a developer account.
Login developer background and select the function menu "Application Management --> Application List", click the "Add" button in the upper right corner to create app.
Note::
Login developer background and select the function menu "Advertising platform --> Ad space list". Click "Add" button in the upper right corner to create Ad space. After the addition, an "Ad Space Primary Key" will be generated for each Ad space. "Ad Space Primary Key" is used to access Ad space in-game.
Note:
Please click to download Ad SDK
SDK needs to be initialized SDK before accessing to Ad sapce.
The game can access four ad space, they are coopen , banner, insert screen, and exiting screen.
After creating coopen , banner, insert screen ad space in MG background, insert the following code in the relevant location of the game code
try { //This code is to ensure that the ad is added on the main thread, if it is a direct call, you do not need to add this sentence. //But if you ask the server to return data and then add an ad, you need to add this code, because the request server data is called to another thread to operate, the UI belongs to the main thread Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => { MiracleGames.Advertising.UI.AdControl ad = new MiracleGames.Advertising.UI.AdControl("xxxxxxxxxx",”yyyyyyyyyy” true); grid.Children.Add(ad); }); } catch(Exception ex) { string value = ex.ToString(); }
Generally,Coopen advertising space is implemented in the load of MainPage .
Initialize exiting advertising space in Loaded method of mainpage.xaml.cs
if (MiracleGames.ApplicationManager.SetupCompletedSuccessfully) { try { var mgAD = new AdControl("1B4FF5F216", "1B4FF5F216", true); mgAD.CloseIconVisibility = Visibility.Visible; Grid.SetRowSpan(mgAD, 10); RootGrid.Children.Add(mgAD); } catch (Exception) { } }
Register for background events in app.xaml.cs, add the following code in the background event
bool exit = false; private async void App_EnteredBackground(object sender, EnteredBackgroundEventArgs e) { exit = false; var deferral = e.GetDeferral(); await System.Threading.Tasks.Task.Delay(5000); exit = true; deferral.Complete(); }
Add the following code to Suspending event in app.xaml.cs
private void OnSuspending(object sender, SuspendingEventArgs e) { if(!exit) { MiracleGames.Advertising.AdvertisingManager.ExitAd(); } var deferral = e.SuspendingOperation.GetDeferral(); deferral.Complete(); }
Register OnActivated events in app.xmal. Cs
protected override void OnActivated(IActivatedEventArgs args) { MiracleGames.Advertising.AdvertisingManager.ToastAd(args); base.OnActivated(args); }