Windows 手机广告不起作用 [英] Windows phone ads not working

查看:19
本文介绍了Windows 手机广告不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将广告集成到已成功部署的应用中.然而,无论我做什么,我似乎都无法让广告发挥作用.我尝试使用代码版本和拖放 gui 版本.这两个我都不能上班.

这就是我所看到的:当它启动时,它可能会在广告应该出现的地方闪烁一瞬间的白色,但仍然没有添加.它识别出我放置它的位置,当我将它放在按钮上时,该按钮变得不可点击.话虽如此,没有弹出默认的微软广告"图像.我已经安装了广告 SDK,并且已经成功地能够轻松地在其他项目中展示广告.

什么给?这是非常简单的页面,我无法弄清楚出了什么问题.似乎我也不能在任何其他页面上放置广告...我确实有 Microsoft.Advertising.Mobile 和 Microsoft.Advertising.Mobile.UI 包含在项目中,我的互联网正在运行(我有一个项目同时打开并带有广告并且可以运行)

<!--LayoutRoot 是放置所有页面内容的根网格--><Grid x:Name="LayoutRoot" Background="Transparent"><Grid.RowDefinitions><RowDefinition Height="自动"/><RowDefinition Height="*"/></Grid.RowDefinitions><!--TitlePanel 包含应用程序名称和页面标题--><StackPanel x:Name="TitlePanel" Margin="12,17,12,28"><TextBlock x:Name="PageTitle" Text="谢谢!"Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" Width="334"/></StackPanel><!--ContentPanel - 在此处放置附加内容--><Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0" Height="569" VerticalAlignment="Top"><Button Content="Ok" Height="72" Horizo​​ntalAlignment="Center" Margin="0,428,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click"/><my:AdControl AdUnitId="Image480_80" ApplicationId="test_client" Height="80" Horizo​​ntalAlignment="Left" Margin="-12,458,0,0" Name="adControl1" VerticalAlignment="Top" Width="480"/></网格></网格></phone:PhoneApplicationPage>

使用系统;使用 System.Collections.Generic;使用 System.Linq;使用 System.Net;使用 System.Windows;使用 System.Windows.Controls;使用 System.Windows.Documents;使用 System.Windows.Input;使用 System.Windows.Media;使用 System.Windows.Media.Animation;使用 System.Windows.Shapes;使用 Microsoft.Phone.Controls;使用 Microsoft.Advertising.Mobile.UI;使用 Microsoft.Advertising.Mobile;命名空间 Stickey_Note_v._1{公共部分类 AdPage : PhoneApplicationPage{公共广告页(){初始化组件();}private void button1_Click(对象发送者,RoutedEventArgs e){NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));}}}

解决方案

我遇到了同样的问题并写了一篇博客文章 关于它.这是重要的东西:

SDK 的AdControl 问题的症状似乎非常一致:页面加载,控件短暂闪烁,显示 1 像素帧的提示,然后,.它坍塌为虚无,只留下一个绝望的黑洞.

理论上,设置AdControl 很简单.文档来自 Microsoft 概述了基础知识:

  • 下载并安装 Microsoft Advertising SDK.
  • 添加对 Microsoft.Advertising.Mobile.UI 的引用.
  • 将控件拖到 Visual Studio 设计器中的页面上.
  • AdUnitIdApplicationId 属性设置为测试值或实际实时值,您可以从 Microsoft pubCenter 获取这些值.

但没那么容易.我仔细地遵循了文档,但没有任何效果.我什至无法显示测试广告,这看起来很奇怪.我什至恢复到我的应用程序的旧版本(是的源代码管理!)并放入新的 .dll.失败.

最后,我在一个晦涩的论坛帖子中找到了线索.

Microsoft 文档忽略了几个重要的细节.如果您像我一样将现有项目升级到 Mango 广告 SDK,则需要特别注意以下几点:

  • 您必须为 AdControl 指定高度和宽度.如果没有指定HeightWidth 属性,或者将它们设置为auto,将会导致沮丧的眼泪.我建议使用 80 像素高和 480 像素宽,因为这是 Microsoft 提供的广告的原始尺寸.
  • 似乎不能在同一个页面上有两个 AdControls,或者至少不能在同一个父元素中.第二个会崩溃.可能有办法解决这个问题,但我在构建我的演示应用程序时发现了它,并且不在乎寻求解决方案.
  • 您必须在 WMAppManifest.xml 文件中指定某些功能.由于我正在升级我的应用程序,因此我没有声明一些较新的功能.导致所有麻烦的是ID_CAP_IDENTITY_USER.控件正常运行需要以下功能:
<块引用>

<能力名称="ID_CAP_IDENTITY_USER"/><能力名称="ID_CAP_MEDIALIB"/><能力名称="ID_CAP_NETWORKING"/><功能名称="ID_CAP_PHONEDIALER"/><能力名称="ID_CAP_WEBBROWSERCOMPONENT"/></能力>

希望有帮助!

I am trying to integrate ads into a already successful deployed app. However no matter what I do, I cannot seem to get the ads working. I have tried using both the code version and the drag n' drop gui version. Neither of which I can get to work.

This is what I see: When it starts up it may flash for a split second white, where the ad is supposed to be, but none the less, no adds. It recognizes that it is where I place it, when I place it over a button, the button becomes unclickable. All being said, no default "microsoft advertising" image pops up. I have installed the ad SDK and have successfully been able to make the ads display in other project with ease.

What gives? This is very simple page and I cannot figure out what is wrong. It also seems that I cannot place an ad on any of the other pages either... I do have the Microsoft.Advertising.Mobile and Microsoft.Advertising. Mobile.UI included in the project and my internet is working (I have an project open at the same time with ads and it works)

<phone:PhoneApplicationPage 
    x:Class="AppName.AdPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True"
    xmlns:my="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Margin="12,17,12,28">
            <TextBlock x:Name="PageTitle" Text="Thank You!" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" Width="334" />
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0" Height="569" VerticalAlignment="Top">

            <Button Content="Ok" Height="72" HorizontalAlignment="Center" Margin="0,428,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click" />
            <my:AdControl AdUnitId="Image480_80" ApplicationId="test_client" Height="80" HorizontalAlignment="Left" Margin="-12,458,0,0" Name="adControl1" VerticalAlignment="Top" Width="480" />
        </Grid>
    </Grid>
</phone:PhoneApplicationPage>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Advertising.Mobile.UI;
using Microsoft.Advertising.Mobile;
namespace Stickey_Note_v._1
{
    public partial class AdPage : PhoneApplicationPage
    {
        public AdPage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }
    }
}

解决方案

I had the same issue and wrote a blog post about it. Here's the important stuff:

The symptoms of a problem with the SDK's AdControl seem to be pretty consistent: The page loads, the control flickers briefly, showing the hint of a 1 pixel frame, and then, poof. It collapses into nothingness, leaving only a black hole of dispair.

In theory, setting up the AdControl is simple. The documentation from Microsoft outlines the basics:

  • Download and install the Microsoft Advertising SDK.
  • Add a reference to Microsoft.Advertising.Mobile.UI.
  • Drag the control onto the page in the Visual Studio designer.
  • Set the AdUnitId and ApplicationId properties to either test values or actual live values, which you can obtain from Microsoft pubCenter.

But it couldn't be that easy. I followed the documentation carefully, but nothing was working. I couldn't even get test ads to show up, which seemed really weird. I even reverted to an older version of my app (yay source control!) and dropped in the new .dll. Failure.

Finally, I found a clue in an obscure forum post.

The Microsoft documentation neglects to mention several important details. You need to pay particular attention to the following if you're upgrading an existing project to the Mango ad SDK, as I was:

  • You must specify a height and width for the AdControl. Failing to specify the Height and Width attributes, or setting them to auto, will cause tears of frustration. I'd recommend 80 pixels high and 480 pixels wide, as that's the native size of the ads that Microsoft serves up.
  • It seems that you can't have two AdControls on the same page, or at least not in the same parent element. The second one will collapse. There might be a way around this, but I discovered it while building my demo app and didn't care to pursue a solution.
  • You must must must specify certain capabilities in your WMAppManifest.xml file. Since I was upgrading my app, I didn't have some of the newer capabilities declared. The one that was causing all the trouble was ID_CAP_IDENTITY_USER. The following capabilities are all required for the control to function correctly:

<Capabilities>
    <Capability Name="ID_CAP_IDENTITY_USER"/>
    <Capability Name="ID_CAP_MEDIALIB"/>
    <Capability Name="ID_CAP_NETWORKING"/>
    <Capability Name="ID_CAP_PHONEDIALER"/>
    <Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>
</Capabilities>

Hope that helps!

这篇关于Windows 手机广告不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆