问题
Ok, I have a simple and silly question, maybe someone could clarify for me.
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."
Now, would this be in App.xaml.cs OR in MainPage.xaml.cs
I did my work in App.xaml.cs (Correct Place)
However, it is not working
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)
回答1:
I got it working!
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);
}
来源:https://stackoverflow.com/questions/40938804/microsoft-store-engagement-services-dev-center-push-notifications-uwp-c-sharp