Azure Notification not working window app based

Murali J 1 Reputation point
2020-11-05T13:24:48.227+00:00

Hi I tried to use windows app based notification using azure
Created Developer Portal
Created the App
On product management
WPN/MSPN click and clicked on Live Services site.
Copied the Application Secrets and Package SID

In Azure Portal Created Notification hub Namespace creating notification and in left navigation on setting selected Windows WNS pasted the Copied the Application Secrets and Package SID
In Access policies copied the key who can manage read and write

In Visual studio creating UWP appxaml.cs and creating the Notification hub

private async void InitNotificationsAsync()
{
    //  var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
    var channel = await Windows.Networking.PushNotifications.PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();

    var hub = new NotificationHub("Notification Name ""Access policies copied from Azure");
    var result = await hub.RegisterNativeAsync(channel.Uri);

    // Displays the registration ID so you know it was successful
    if (result.RegistrationId != null)
    {
        var dialog = new MessageDialog("Registration successful: " + result.RegistrationId);
        dialog.Commands.Add(new UICommand("OK"));
        await dialog.ShowAsync();
    }
}

/// <summary>
/// Invoked when the application is launched normally by the end user.  Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
    InitNotificationsAsync();

    Frame rootFrame = Window.Current.Content as Frame;

    // Do not repeat app initialization when the Window already has content,
    // just ensure that the window is active
    if (rootFrame == null)
    {
        // Create a Frame to act as the navigation context and navigate to the first page
        rootFrame = new Frame();

        rootFrame.NavigationFailed += OnNavigationFailed;

        if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
        {
            //TODO: Load state from previously suspended application
        }

        // Place the frame in the current Window
        Window.Current.Content = rootFrame;
    }

    if (e.PrelaunchActivated == false)
    {
        if (rootFrame.Content == null)
        {
            // When the navigation stack isn't restored navigate to the first page,
            // configuring the new page by passing required information as a navigation
            // parameter
            rootFrame.Navigate(typeof(MainPage), e.Arguments);
        }
        // Ensure the current window is active
        Window.Current.Activate();
    }
}

Published using Associate App with Store

**

  • Issue

**
When I try to Send the Message from Azure portal other than Toast nothing works
It means if I sent a message I get receiving only toast notification type

In Toast message also I receiving below Error Like below

The Notification was successfully sent to the Push Notification System
The Token obtained from the Token Provider is wrong

**

  • Questions

**

If token provider wrong means how could I able to get notification on toast this my first question

Why the Token Provider wrong I made everything right (secret key and Package SID)

Why other than Toast (Tile,badges,Text) why is not working

Azure Notification Hubs
Azure Notification Hubs
An Azure service that is used to send push notifications to all major platforms from the cloud or on-premises environments.
319 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 28,106 Reputation points Microsoft Employee
    2020-11-05T16:32:30.457+00:00

    Hi @Murali J ,

    It sounds like you're having the same issue that was identified over on GitHub. On your app registration page under https://apps.dev.microsoft.com/, there's a Windows Store section. This section as a box under Application Identity. Make sure that you replace <Identity ... /> in your Package.appxmanifest file with value you see under Application Identity. We've updated the doc to include this omitted step.

    Regards,
    Ryan


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.