Ads on Phone 8

Here is mine. You can  copy past it if you like. Make sure  that you can see the new view you add in your grid layout view. it might be off screen. Change your positioning as you need it. This is currently set for middle bottom. 

  <DrawingSurfaceBackgroundGrid x:Name=“fDrawingSurfaceBackgroundGrid” Grid.Row=“1” Margin=“12,0,12,0”>

        <corona:CoronaPanel x:Name=“fCoronaPanel”>

            <UI:AdControl x:Name=“ad1”

                          ApplicationId=“LALALA not telling you”

                          AdUnitId=“or this either”

                          HorizontalAlignment=“Center” 

                          Height=“60” 

                          Margin="-0,-10,0,0" 

                          VerticalAlignment=“Bottom” 

                          Width=“320” 

                          IsAutoCollapseEnabled=“True”/>

        </corona:CoronaPanel>

    </DrawingSurfaceBackgroundGrid>

IF you cant see ads. make sure you put back the default ids so you see the test ad on simulator. if you see test ad but not actual ads then campaign is not on. if you dont see test ad then its either off screen or you might have placed it outside the main grid object

@Rob,

That got it.

I did not think to place the Ad control inside the CoronaPanel. I had created a stack panel and was trying to get that to work.

But your way is better. On my little laptop the simulator went nuts flickering on every frame, but on the divice its smooth.

i added some funky code to toggle the ads on an off, with the Lua dispatch events but it is all working pretty well.

@SpaceWolf

Let me clean up my code a bit and I’ll upload it to my website. I’ll try to tackle this on tuesday evening.

Thanks for the assist Rob and everyone else.

Larry

Great news @doubleslashdesign!

I am looking forward to seeing the ad sample codes :slight_smile:

Glad to help Larry. Notice on google docs they don’t add “name” parameter. I tried this when I needed to hide/unhide it. Adding the name allowed this. Also added extra bits like auto collapses although this will remove the black square if no banner is available so might look like it’s not working. Best to disable this till it’s all working.

Josh it does seem to stop it exiting now thats great thanks

So now I have Google Banners and Google Interstitial and Windows Banners working. 

Happy to help!  Glad it’s working for you now.  :)

Just wanted to chime in here with an FYI. I’ve had native apps on windows phone for a few years now and this is what I have found with advertising:

Pubcenter (microsoft ads)

Fill rate: 69%

Ecpm: $0.32

Admob

Banner ads

Fill rate: 99%

ecpm: $0.06

Inmobi

Banner ads:

Fill rate: 0%

ecpm: ???

I don’t know how interstitial ads will perform. It’s possible they would be better.

My advice for advertising on windows phone is to ALWAYS use pubcenter first, then fall back to admob if pubcenter has no ad to serve.

I have not added the  interstitial google - ad mob. But I will in my next updated version.

I’m almost done with the clean up, and a little write up on my functions.

I’ll have it done by this weekend.

Larry

JOSHUA, I can now invoke the interstitial ID direct from LUA so this is very handy for code re-use.

Im trying to do the same with the banner but while this code is outside the mainPage I am having difficulty adding as a child object:

This line doesnt work as I need top reference / link to ContentPanel which is outside my CS file.

How can I link/reference ContentPanel from the mainPage.cs/xaml to my CS file?

 ContentPanel.Children.Add(bannerAd);

Currently, we have no plans on adding ads support on WP8.  At least in the next several months.  We’re more focused on polishing up our core features right now.  For example, we’re in the middle of adding support for our Lua “network” library for async http communications.

But you should be able to easily implement ad support for yourself via C#.  Microsoft’s ad library is pretty simple to use.  And we have an example on how to communicate between Lua and .NET (link below) so that you can show/hide ads via Lua.

   http://docs.coronalabs.com/daily/coronacards/wp8/index.html#lua-interop-communications

If you need help, just let me know.  Although I’ve seen that you’ve already implemented in-app purchase, so, you might already be an expert in Lua/.NET bridging now.  :slight_smile:

Not a problem, that is just what I expected.

When I am done getting the kinks of my app then I’ll create a sample APP and post the code :slight_smile:

Larry

You posting some sample code would be greatly appreciated!

If you have anything blocking you or features needed in the near future, then please let us know.  It’ll help us prioritize what we need to work on next.  Thanks!

Very nice thanks, yeah when I get that far I’ll let you know.

Larry

Also running into an issue now with Interstitial ads. Ive noticed a big slow down when using Runtime enter frame events after an Interstitial has been created. It runs well if I dont create the ad but like a dog if I do. It seems that although the ad is dismissed, it is doing something still. I need to be able to remove it.

So, this is the code to create the ad:

interstitialAd = new InterstitialAd(adUnitID);

            AdRequest adRequest = new AdRequest();

            // Enable test ads.

            // adRequest.ForceTesting = true;

            interstitialAd.ReceivedAd += OnAdReceived;

            interstitialAd.LoadAd(adRequest);

            interstitialAd.FailedToReceiveAd += OnFailedToReceiveAd;

            interstitialAd.DismissingOverlay += OnDismissingOverlay;

Now what can I do to remove all that completely? Is there some kind of removeSelf for c#? Do i remove the instance I created :interstitialAd

and then

AdRequest 

OnDismissingOverlay is an empty void which just lets me know it has been dismissed so I just need to place whatever code in there.

?

First, I recommend that you add the AdView (ie: AdMob’s banner ad) to your CoronaPanel.  That way it’ll always be rendered/displayed on top of Corona.  Or at least add your ContentPanel to the CoronaPanel.  You can do so as follows…

   fCoronaPanel.Children.Add(bannerAd);

When you want to remove the ad banner from the page, then you remove it from the “Children” collection.  This is the equivalent to Corona’s DisplayGroupObject:remove() function in Lua.  You can do so as follows…

   fCoronaPanel.Children.Remove(bannerAd);

Hopefully, Google coded this right on their end and set up their AdView to stop requesting ads from the Internet when it has been “Unloaded” from the page, which happens when you remove it.

Regarding interstitial ads slowing down your app, I’ve only noticed this happening the first time I called LoadAd().  I didn’t see any slow-downs after showing/dismissing the interstitial ad or with subsequent calls to LoadAd().  I’ve tested this with our “Physics\ManyCrates” sample app that I cranked up to 60 FPS.

Also, is there a reason why you’re hooking into “enterFrame” events?  What are you using it for?

I dont need to remove the banners. They arent causing any problem. They are fine.

 I need to find away to remove interstitial as in the code above - i need to remove al instances of it and see if that works. I dont know if it will.

What I have running on enterframe  an on screen  touch event running and an audio function that wobbles pitch. It all works fine until an ad comes up an is dismissed. Its as if its still there.

Im just porting something across that works fine on Android and IOS and actually does work on Windows Phone until the Interstitial is dismissed.

I am walking Throuhgh the Windows Phone 8.1 Ads tutorial to create a sample app.

the tutorial says I need a Package.appxmanifest file…

Add the Internet (Client & Server) Capability to the Package.appxmanifest. In Solution Explorer , double click

Package.appxmanifest.

the Corona Extension did not create one by default is there a reason for this?

Here is the link

http://msdn.microsoft.com/en-US/library/advertising-mobile-windows-phone-ads-walkthroughs-81-silverlight-markup%28v=msads.20%29.aspx

Thanks

Larry

The APIs provided by Google’s InterstialAd is very limited.  There is no means of removing anything via their class.  I would assume that Google creates a XAML page when showing an interstial ad and then they remove the page from the app when you back out of it or tap the (x) button.  Also, since it’s .NET based, the garbage collector would not immediately destroy the interstial ad’s page.  So, you could try forcing garbage collection yourself when returning to your MainPage.  You can do that in .NET via the static System.GC.Collect() method.  Just be warned that doing this will likely cause a short performance hit.

   http://msdn.microsoft.com/en-us/library/system.gc.collect(v=vs.110).aspx

Also, does your app perform better without the “enterFrame” event?

I ask because I’m not seeing this performance issue in my interstiad ad example app.  But also, performing a lot of work on every frame is a very expensive thing to do on all platforms.  I suggest that you start looking in your enterFrame code first.

I would normally but it captures motion and redraws on screen. If it goes slower then it wont be as smooth. Also theres an LFO style pitch control happening at the same time and needs to be smooth. I will see about maybe thinning the updates down a little. I wonder if its related to movement events as in mentioned previously. Even so as I said it works fine and as it should If I dont use interstertial ad at all. Maybe Im better of just not using it for this particular project.

I tried that system.gc.collect and no joy. Even nulled everything first. I was wondering how I could possibly use some kind of Destroy or Dispose.