[UWP] PushTrigger background task not invoking

Sarath Vanga 6 Reputation points

I am building a Unity game application targeted for UWP. My aim to add WNS push notifications to the project. I am using raw push notifications.

For raw push notifications to work I followed this link https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/raw-notification-overview.

As specified in the link above, I have added one Background task for PushNotificationTrigger and also added this task in the package manifest file. I am receiving the push notification via 'PushNotificationReceived' event when the app is in foreground, but when the app is NOT live, the background task never got invoked. When I check the 'Event Viewer' application for details, I found this error "The background task with entry point UWPNotifications.PushBackgroundTask and name uwpnotifications.pushbackgroundtask failed to activate with error code 0x80270254."
The background task code looks like this:

     public sealed class PushBackgroundTask : IBackgroundTask  
        private const string TASK_NAME = "notif_push_task";  
        public static void Register()  
            if (IsBackgroundTaskRegistered(TASK_NAME))  
                Console.WriteLine("Push background task already registered");  
            BackgroundTaskBuilder builder = new BackgroundTaskBuilder();   
            builder.TaskEntryPoint = typeof(PushBackgroundTask).FullName;  
            builder.Name = TASK_NAME;  
            builder.SetTrigger(new PushNotificationTrigger());  
                BackgroundTaskRegistration task = builder.Register();  
            } catch(Exception ex)  
                Console.WriteLine("Push task registration failed {0}", ex.Message);  
        public void Run(IBackgroundTaskInstance taskInstance)  
            RawNotification notification = (RawNotification)taskInstance.TriggerDetails;  
            Console.WriteLine("Raw WNS content {0}", notification.Content);  

        private static bool IsBackgroundTaskRegistered(string name)  
            foreach (var task in BackgroundTaskRegistration.AllTasks)  
                if (task.Value.Name == name)  
                    return true;  
            return false;  

What is the issue here? I have created the application package from "Publish --> Create app packages --> Microsoft Store app as AppName" and installed this on my windows10 pc for testing.

I have a few other doubts regarding the WNS raw notifications and background tasks.

  1. Is it mandatory that the background task code should be present as a separate library(.winmd) ?
  2. Are there any restrictions on background task name? Can we have a custom name to it ?
  3. Is there a way to test WNS push notifications with out the need to generate the store package ?

I appreciate any help on this.


Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,549 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Enrico Rossini 186 Reputation points

    By any chance, did you fix this issue? How? Thank you in advance, Enrico

    0 comments No comments