1

I am developing a Windows Phone 8.1 Runtime Application (XAML but not Silverlight).

My issue is which PubCenter Ad size should I show in my application.

Currently, PubCenter for phone supports 4 different sizes:

  1. 300 X 50
  2. 320 X 50
  3. 480 X 80
  4. 640 X 100

My question is :

  1. Is there a single size which I can use regardless of the device size (such that it can auto scale).
  2. Or based on the users' device size should I set the Width , Height & AdUnitId in code behind. If this is the right option how to enable this.

(Basically, I don't want to waste any precious real estate on the users phone. Want to show the biggest ad based on the users screen size)

Thanks.

Saqib Vaid
  • 412
  • 5
  • 21

2 Answers2

2

This article gives a good understanding of which format to use on Windows Phone 8.1 RT apps:

Use the Recommended AdUnit Format Size and AdControl Size

I was able to achieve this with the below piece of code. So for most Lumia phones it would take the 320 x 50 size as recommended in the msdn article. But for phones with bigger screens it would take the other sizes.

Few things to make sure :

  1. The ad units are already defined in the pubcenter. Separate ad units for each size.
  2. The adcontrol must be placed inside a container with sufficient size.

    #region Initialize Ad Control
        //var scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
        //Debug.WriteLine("The current resolution is {0}x{1}", Window.Current.Bounds.Width * scaleFactor, Window.Current.Bounds.Height * scaleFactor);
    
        double pageWidth = 0;
        //pageWidth = Window.Current.Bounds.Width * scaleFactor;
        pageWidth = Window.Current.Bounds.Width;
    
        AdUnit.ApplicationId = "abcdefgzzzz-zz-zz-z-zz";
        //AdUnit.ApplicationId = "test_client";
    
        if (pageWidth < 480) //Use 320
        {
            AdUnit.Height = 50;
            AdUnit.Width = 320;
            //AdUnit.AdUnitId = "Image320_50";
            AdUnit.AdUnitId = "320-ZZZZ";
        }
        else if (pageWidth >= 480 && pageWidth < 640) //Use 480
        {
            AdUnit.Height = 80;
            AdUnit.Width = 480;
            //AdUnit.AdUnitId = "Image480_80";
            AdUnit.AdUnitId = "480-ZZZZZ";
        }
        else if (pageWidth >= 640)
        {
            AdUnit.Height = 100;
            AdUnit.Width = 640;
            AdUnit.AdUnitId = "640-ZZZZ";
        }
        #endregion
    
Saqib Vaid
  • 412
  • 5
  • 21
0

Nop, i don't think you'll be able to change the ads according to the device size. As they have provided the only available sizes by default.

For more refer here:

Microsoft Ad SDK

Set up ads in Windows Phone 8

Hope it helps!

Community
  • 1
  • 1
Kulasangar
  • 7,225
  • 3
  • 36
  • 71