创建 UWP 应用内广告

文章目录

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

    Monetize (货币化) - “In-app ads”

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

    创建 UWP 应用内广告

    Ad unit type

    • banner 页面固定广告
    • banner interstitial (游戏关卡间切换时展示)
    • Video interstitial (游戏关卡间切换时展示)
    • native 本地广告

    下载并安装广告 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 编译参数。