Wednesday, August 14, 2013

Implemention of Microsoft Advertising sdk in windows 8 app

Before you can use the SDK, you must have Windows 8, a version of Visual Studio 2012 for Windows 8, and the Advertising SDK installed on your system.

Walkthrough

  1. From the Solution Explorer window, double-click the “Package.appxmanifest” file.


    2.Select the Capabilities tab, and ensure that the Internet Client check box is selected. Without this capability, the ad client cannot make calls to the Internet to fetch ads.

    3.From the Solution Explorer window, right click References, and then select Add Reference.

    4.Click Windows, and that will expand to show Extensions. Click Extensions, select Microsoft Advertising SDK for Windows 8 (XAML), and then click OK.


    Modify the XAML for the page where you are embedding advertising to include the Microsoft.Advertising.WinRT.UI namespace. For example, in the default sample app generated by Visual Studio (named, in this app, My Ad Funded Windows 8 XAML App), the XAML page is MainPage.XAML.
    Include the line of code xmlns:UI="using:Microsoft.Advertising.WinRT.UI" before x:Class="My_Ad_Funded_Windows_8_XAML_App.MainPage".

    <Page
        xmlns="http://schemas.microsoft.com/winfx/2006/XAML/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/XAML"
        xmlns:local="using:My_Ad_Funded_Windows_8_XAML_App"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:UI="using:Microsoft.Advertising.WinRT.UI"
        x:Class="My_Ad_Funded_Windows_8_XAML_App.MainPage"
        IsTabStop="false"
        mc:Ignorable="d">
    
        <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        </Grid>
    </Page>
    
    
    In the Grid tag, add the code for the AdControl. The complete Grid tag looks like this code.
    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <UI:AdControl 
                ApplicationId="813a1da4-2bd1-4ec6-9842-f62cefbf0257" 
                ApplicationId="813a1da4-2bd1-4ec6-9842-f62cefbf0257"              AdUnitId="10140720"              HorizontalAlignment="Center"              Height="90"              Margin="0,0,0,0"              VerticalAlignment="Bottom"              Width="728"/>
    </Grid>


No comments:

Post a Comment