创建 UWP 应用内广告

发布时间: 2018-09-02 21:09:31 作者: 大象笔记

在微软 Partner Dashboard 中,选择左侧菜单

Monetize (货币化) - "In-app ads"

https://partner.microsoft.com/dashboard/monetization/ads/

Ad unit type

下载并安装广告 SDK

https://docs.microsoft.com/en-us/windows/uwp/monetize/install-the-microsoft-advertising-libraries

用 NuGet 更合理。

添加引用

Solution Explorer - 右键 References - Add Reference

XAML 中添加广告单元

https://docs.microsoft.com/en-us/windows/uwp/monetize/adcontrol-in-xaml-and--net

第一次添加可能会报错,忽视,直接编译测试就行。

替换测试用的 ApplicationId and AdUnitId

In your code, replace the test ad unit values (ApplicationId and AdUnitId) with the live values you generated in Dev Center.

但是如何保证开发调试期间不使用线上广告 ID 呢?

因为文档里说,禁止调试开发期间使用线上广告 ID。

改天尝试一下 DEBUG 编译参数。

我是一名山东烟台的开发者,联系作者