Handling toast notification action trigger from background task - UWP - win-universal-app

I have a background task for a UWP which can be triggered once a push notification occurs, but I want to trigger the task for normal toast notifications activated when the App is in background.
I found that ToastNotificationActionTrigger can do so but it can only trigger the BG task when the activation type is set to background for that notification.
Is there a work around for differentiating when a toast notification is received and activated with App in BG with that of a toast notification activated in Foreground.

ToastNotification class has an Activated event so you can attach an event handler once you create it to receive Activation events without a background task.
Occurs when user activates a toast notification through a click or
touch. Apps that are running subscribe to this event.
In order to receive activation events from toasts that are created by previous instances of the app, you also need to enumerate current toast notifications on app launch using the ToastNotificationManager class and attach an event handler to them as well.

Related

sceneDidEnterBackground( and applicationDidEnterBackground( not getting called when the app is launched in the background

I have a location service running with background mode capabilities, and according to apple docs the app will call sceneDidEnterBackground() or applicationDidEnterBackground() if the app was launched in the background due to location event or if the app was suspended and received a location event. I am not witnessing this happening.
These methods are only called when the user moves away from the apps.
I am more concerned with the scenario where the app is suspended and gets move to background due to a location event as that is my only point of connection to execute code.

show notification when task is enqueued in work manager

I have a video uploading work that is handled by the work manager. When the user clicks the upload button, I want to show the notification with indeterminate progress bar and when the task starts, show the progress in the same notification.
I passed the notificationID to the work through workData and the progress is shown properly.
The issue is: If there is no internet connection, the indeterminate progress bar is shown and the work is not started (It is enqueued). When I close the app, the indeterminate progress bar is also dismissed and the enqueued task is not shown to the user.
How to make sure the notification persist even on app close or when the work manager has work enqueued to it?

How to retry sending events from Azure Event Grid to Logic Apps

I have an event grid which publishes a lot of events, and a logic app which needs to consume some of them. These events aren't guaranteed to be in order, and events which require another event to be processed first, might end up in the logic app prematurely, causing them to fail.
From the documentation, I can see that event grid supports a retry policy, with an increasing time interval. This would solve my problem.
However, it seems like the logic app in question, always acknowledges events from the event grid, even though the process is stopped early with the Terminate action in the failure state and with an error code.
From the logic app overview, the runs are shown as failed. But the event grid never attempts a retry, and seems to consider the events successful. What can I do to make the event grid retry failed logic app runs?
It seems that once the Azure logic app is triggered, the event in the Azure event grid is considered to be processed.
I think you can configure retry policy at the step where your Azure logic app failed, please refer to Retry policies.
Take the example of Httpaction:
You can click ··· in the upper right corner of the Http action, then click Settings, and select the type you want under Retry Policy:
Event Grid will retry depending on how you terminate your Logic App. If you terminate using http response action (status code 500) then event grid will attempt retries.
Now, depending on what is going on in your Logic app, handle the failures in a way that it terminates on http response action with status code 500.

Listen to task canceled event in the browser

I am using Twilio Taskrouter for making reservations for a video call. What I want is to notify the user that all workers are currently busy, with a message displayed for the user on the browser. So I wanted to know how can one catch the task.canceled event in the browser so that I can notify the user about the task getting canceled due to the task timeout. I have seen the JS SDK for Twilio but I only saw events for Workers, Workspace and Task Queues and couldn't find any such events for Tasks, so is there anyway I can listen to the task's events on the browser side?
I think there is a way to get the assignment status of the task, more details can be found here: TaskRouter Task Resource. On this page look for assignmentStatus resource property. The current status of the Task's assignment. Can be: pending, reserved, assigned, canceled, wrapping, or completed
let me know what you think.

Check the response of a 'Send Event' Logic App action

I have a Logic App that sends an event to a specified Event Hub using the Send Event action.
It seems that regardless of whether or not the event is accepted by the specified Event Hub, the Logic App continues on regardless. Unlike the Azure Functions action, there appears to be no automatically generated StatusCode property available for Send Event action.
Is it possible to check the response from Event Hubs so that I may determain whether or not to halt execution?
Update
After a completed run, it seems that there is a status code returned by Event Hubs, although unusually it seems to be 200 where as typically when sending events it's 201.
However, when editing the Logig App, there doesn't seem to be any way of accessing that status code in order to check the success/failure of the send event action.
You should be able to use #outputs('Send_event')?['statusCode'] to access the status code.

Resources