Microsoft Store Engagement Services - 开发中心推送通知 UWP C# [英] Microsoft Store Engagement Services - Dev Center Push Notifications UWP C#

查看:263
本文介绍了Microsoft Store Engagement Services - 开发中心推送通知 UWP C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我有一个简单而愚蠢的问题,也许有人可以为我澄清一下.

Ok, I have a simple and silly question, maybe someone could clarify for me.

在 Microsoft 提供的说明中,他们指出1. 在您的项目中,找到在启动期间运行的一段代码,您可以在其中注册您的应用以接收开发中心通知."

In the instructions provided by Microsoft, they state "1.In your project, locate a section of code that runs during startup in which you can register your app to receive Dev Center notifications."

现在,这是在 App.xaml.cs 中还是在 MainPage.xaml.cs 中

Now, would this be in App.xaml.cs OR in MainPage.xaml.cs

我在 App.xaml.cs(正确位置)中完成了我的工作

I did my work in App.xaml.cs (Correct Place)

然而,它不起作用

Microsoft 提供的说明含糊不清.他们提供的示例也没有提示在何处注入代码或使用哪种方法.我希望他们能给出一个整页的例子.我至少可以不用问就知道去哪里了.

The instructions provided by Microsoft were vague. The example they provide also gives no hint of where to inject the code or which approach to use. I wish they would have given a full page example. I would at least understand where what goes without having to ask.

(更新/自我回答:希望这对某人有所帮助)

(Update/Self Answered: Hope this helps someone)

推荐答案

我成功了!

using Microsoft.Services.Store.Engagement;

  public App()
    {
        this.InitializeComponent();
        this.Suspending += OnSuspending;
        RegisterNotificationChannelAsync();
    }

    private async void RegisterNotificationChannelAsync()
    {
        StoreServicesEngagementManager manager = StoreServicesEngagementManager.GetDefault();
        await manager.RegisterNotificationChannelAsync();
    }

protected override void OnActivated(IActivatedEventArgs args)
{
base.OnActivated(args);

if (args is ToastNotificationActivatedEventArgs)
{
    var toastActivationArgs = args as ToastNotificationActivatedEventArgs;

    StoreServicesEngagementManager engagementManager = StoreServicesEngagementManager.GetDefault();
    string originalArgs = engagementManager.ParseArgumentsAndTrackAppLaunch(
        toastActivationArgs.Argument);

} 

这篇关于Microsoft Store Engagement Services - 开发中心推送通知 UWP C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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