How can I integrate Windows Ads in Universal App for windows phone? cocos2d-x 3.6

Hi,
I want to take part in windows contest. For this I’m creating a simple game which I want to monetize using ads … so simple so typical. This is my first experience with windows phone and I have no clue of how integrate windows ads. I have download the component “Microsof Advertisting SDK for Windows Phone 8.1 (XAML)” and added as dependency on my Windows Phone 8.1 project. But I do not know how to continue … some tutorials I have found are really dated and none of them address the “universal app”. Every screenshot I see has some C# project which I can not see in my solution (I guess its due an older way of developing WP8 apps using cocos2d-x, no idea).

Can anyone help me?
Thanks

1 Like

Okey finally I figured it out !

It was not clear to me that I had to download cocos from special fork made by MS

In case anyone else has troubles, I will describe a very dummy guide of what I did:

  • clone from https://github.com/MSOpenTech/cocos2d-x
  • create project
  • retarget project to windows 8.1
  • add a Canvas layer in MainPage.xaml (mine is , you should adjust to your needs margins etc))
  • add your Ad in CS code MainPage.xaml.cs,
    include the using statement using Microsoft.Advertising.Mobile.UI;

inside function DrawingSurfaceBackground_Loaded

AdControl adControl;
adControl = new AdControl(“test_client”, “Image480_80”, true);
adControl.ErrorOccurred += OnAdError;
adControl.Width = 480;
adControl.Height = 80;
this.Canvas.Children.Add(adControl);

I added OnAdError handler, feel free of doing it if you want.

also add the reference Microsof.Advertising.Mobile and Microsoft.Advertising.Mobile.UI
and the following capabilities:

These capabilities can be set in WMAppManifest.xml

2 Likes

Hello @Dredok
Thank you for sharing this!

But if look at the CHANGELOG then the fork does not contain
[NEW] WP8.1: added back button support ,
and some other interesting fixes.

It seems that I will have to watch a lot of code …

can’t you cherry-pick this fix ?

For me, the biggest issue is that wp8-xaml template uses an old toolchain based in vs2012 and then the c++11 support is worse… so i will have to refactor a lot of code :confused:

hello i have tried your way but still there is xaml or c# file being created even after following the steps …

is there any other way of inserting admob ads in cocos2d-x-3.6 for windows universal apps
Assistance would be greatly appreciated

I am sorry for the late reply. Unfortunately I have not had time to try it,
but I think you need to take MSOpenTech version and manually add the changes described here.
I can only try it a few days later and then I will be able to inform about the result.

actually I figured out how to incorporate ads to an universal app.

I do not know if it is the best way but you can check my steps (roughly) here:
https://github.com/MSOpenTech/cocos2d-x/issues/157

@Dredok - Can you put up your sample code or project ? It will be very useful.

@Dredok
did you use ad manager? could you post your xaml? i cannot make it work as while compiling it tells me it cannot resolve assembly:System.Runtime Version=4.0.10.0