none
[Desktop bridge]The functionality of Desktop Bridge applications sending toast notifications like a UWP application is not working. RRS feed

  • Question

  • After upgrading windows 10 to version 1903 the functionality described below is no longer work.

    "For Desktop Bridge apps, just send toast notifications like a UWP app would. When the user clicks on your toast, your app will be command line launched with the launch args that you specified in the toast."
     

    from document: "social.msdn.microsoft.com/Forums/en-US/newthread?category=windowsapps&forum=wpdevelop"


    Does anyone know how to solve this problem?

    Thanks.


    Monday, September 30, 2019 8:09 PM

All replies

  • Hi,

    I need to confirm something first. Which version it is before you upgrade to Build 1903? The app works correctly in previous version, right? Is there any error message log about this? Could you please add some code to log the error when you send the toast?  That will be very useful to locate the problem. Also it will be better if you could tell me which tutorial you referred to implement this feature?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 1, 2019 2:11 AM
    Moderator
  • Hi Roy,
    Thank you for your considerations.

    Answering your questions:
    1) I don't know how to identify which version was installed, I have Windows Update active and it fires when the site determines. (if there is a way to identify the previous version, let me know)

    2) The application in question was working before the upgrade. I am working on it daily.

    3) There is no log, only the process does not start when prompted by the Toast action. (I tried to use foreground and background in the activationType parameter the result was the same in relation to App Start, ie it did not start).

    4) I am using Visual Studio 2019 Community to write the code and use the templates that are available in this software.

    Microsoft Visual Studio Community 2019
    Version 16.3.1
    VisualStudio.16.Release/16.3.1+29324.140
    Microsoft .NET Framework
    Version 4.8.03752

    -------------------------------------------------------------------------------------------------

    Here's an example of the Toast code:

       Public Class Toast_Notification
        Private WithEvents Toast As Windows.UI.Notifications.ToastNotification
        Private WithEvents Comun As New Comun

        Public Event ToastError(ByVal Sender As String, ByVal Message As String)
        Public Event ToastActivated(ByVal sender As Windows.UI.Notifications.ToastNotification, ByVal args As Object)
        Public Event ToastDismissed(ByVal sender As Windows.UI.Notifications.ToastNotification, ByVal args As ToastDismissedEventArgs)
        Public Event ToastFailed(ByVal sender As Windows.UI.Notifications.ToastNotification, ByVal args As ToastFailedEventArgs)

        Private Sub Toast_Activated(sender As Windows.UI.Notifications.ToastNotification, args As Object) Handles Toast.Activated
            RaiseEvent ToastActivated(sender, args)
        End Sub

        Private Sub Toast_Dismissed(sender As Windows.UI.Notifications.ToastNotification, args As ToastDismissedEventArgs) Handles Toast.Dismissed
            RaiseEvent ToastDismissed(sender, args)
        End Sub

        Private Sub Toast_Failed(sender As Windows.UI.Notifications.ToastNotification, args As ToastFailedEventArgs) Handles Toast.Failed
            RaiseEvent ToastFailed(sender, args)

        End Sub
      
        Public Function SendToast(ByVal Title As String, ByVal Text As String) As Boolean
            Try
                Dim sbXml As New StringBuilder
                sbXml.Append("<toast launch=""Click"" >")
                sbXml.Append("<visual>")
                sbXml.Append("<binding template=""ToastGeneric"">")
                sbXml.Append("<text id=""1"">")
                sbXml.Append(Title)
                sbXml.Append("</text>")
                sbXml.Append("<text id=""2"">")
                sbXml.Append(Text)
                sbXml.Append("</text>")
                sbXml.Append("<text placement=""attribution"">Funções • Usuários</text>")

                Dim myPicPath As String = "'file:///" & Comun.GetImageResource("PastaQuickDocAut") & "'"
                myPicPath = Replace(myPicPath, "\", "/")

                sbXml.Append("<image placement=""appLogoOverride"" src=" & myPicPath & " alt=""Autorização""/>")
                sbXml.Append("</binding>")
                sbXml.Append("</visual>")
                sbXml.Append("<actions>")
                sbXml.Append("<action activationType=""foreground"" arguments=""OK"" content=""Ver solicitações""/>")
                sbXml.Append("<action activationType=""system"" arguments=""dismiss"" content=""Fechar""/>")
                sbXml.Append("</actions>")
                sbXml.Append("</toast>")

                Dim xmlDoc As New XmlDocument()
                xmlDoc.LoadXml(sbXml.ToString)

                Toast = New Windows.UI.Notifications.ToastNotification(xmlDoc)
                ToastNotificationManager.CreateToastNotifier().Show(Toast)
                Return True
            Catch ex As Exception
                RaiseEvent ToastError("SendToast", ex.Message)
                Return False
            End Try
        End Function

    End Class

    ---------------------------------

    Regards,



    • Edited by D R Mac Tuesday, October 1, 2019 9:07 PM
    Tuesday, October 1, 2019 12:26 PM
  • Hi,

    As I mentioned in my last reply, could you please add some code to log the error when you send the toast so we could know if there is error message for this behavior?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, October 2, 2019 1:37 AM
    Moderator
  • Hi Roy,

    Sorry, the code I am using to generate and send the Toast Notification is in my answer above in Visual Basic. Now I think that I put it in the right place.

    This is Form1.VB code.

    Imports Windows.UI.Notifications
    Public Class Form1
        Private WithEvents Toast As New Toast_Notification
        Private wTextInvoke As String
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
            ClearComponents()
            If Command() <> "" Then
                TxtBoxCommand.Text = "Command Received=>" & Command()
            End If
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            ClearComponents()
            Toast.SendToast("My Title", "My text Bla Bla Bla")
        End Sub
    
        Sub ClearComponents()
            TxtBoxActived.Text = ""
            TxtBoxCommand.Text = ""
            TxtBoxDismissed.Text = ""
            TxtBoxFailed.Text = ""
            LBlError.Text = ""
    
        End Sub
        Private Sub Toast_ToastActivated(sender As ToastNotification, args As Object) Handles Toast.ToastActivated
            Dim outputText As [String] = ""
            outputText = "The user activated the toast =>" & args.arguments.ToString
            If TxtBoxActived.InvokeRequired Then
                wTextInvoke = outputText
                TxtBoxActived.Invoke(New Action(AddressOf SetToastActivated))
                Return
            End If
            TxtBoxActived.Text = outputText
        End Sub
        Private Sub SetToastActivated()
            TxtBoxActived.Text = wTextInvoke
        End Sub
    
        Private Sub Toast_ToastDismissed(sender As ToastNotification, args As ToastDismissedEventArgs) Handles Toast.ToastDismissed
            Dim outputText As [String] = ""
            Select Case args.Reason
                Case ToastDismissalReason.ApplicationHidden
                    outputText = "The app hid the toast using ToastNotifier.Hide"
                Case ToastDismissalReason.UserCanceled
                    outputText = "The user dismissed the toast "
                Case ToastDismissalReason.TimedOut
                    outputText = "The toast has timed out"
            End Select
            If TxtBoxDismissed.InvokeRequired Then
                wTextInvoke = outputText
                TxtBoxActived.Invoke(New Action(AddressOf SetToastDismissed))
                Return
            End If
            TxtBoxDismissed.Text = outputText
        End Sub
        Private Sub SetToastDismissed()
            TxtBoxDismissed.Text = wTextInvoke
        End Sub
    
        Private Sub Toast_ToastError(Sender As String, Message As String) Handles Toast.ToastError
            If LBlError.InvokeRequired Then
                wTextInvoke = Message
                TxtBoxActived.Invoke(New Action(AddressOf SetToastError))
                Return
            End If
            LBlError.Text = Message
        End Sub
        Private Sub SetToastError()
            TxtBoxDismissed.Text = wTextInvoke
        End Sub
    
        Private Sub Toast_ToastFailed(sender As ToastNotification, args As ToastFailedEventArgs) Handles Toast.ToastFailed
            Dim outputText As [String] = ""
            outputText = "Toast Failed:" & args.ErrorCode.Message
            If TxtBoxFailed.InvokeRequired Then
                wTextInvoke = outputText
                TxtBoxActived.Invoke(New Action(AddressOf SetToastFailed))
                Return
            End If
            TxtBoxFailed.Text = outputText
        End Sub
        Private Sub SetToastFailed()
            TxtBoxDismissed.Text = wTextInvoke
        End Sub
    End Class

    This is ToastNotification.VB Code

    Imports Windows.UI.Notifications.Management
    Imports Windows.Data.Xml.Dom
    Imports System.Text
    Imports Windows.UI.Notifications
    
    Public Class Toast_Notification
        Private WithEvents Toast As Windows.UI.Notifications.ToastNotification
        Private ToastTag As String = "MyToastTest"
    
        Public Event ToastError(ByVal Sender As String, ByVal Message As String)
        Public Event ToastActivated(ByVal sender As Windows.UI.Notifications.ToastNotification, ByVal args As Object)
        Public Event ToastDismissed(ByVal sender As Windows.UI.Notifications.ToastNotification, ByVal args As ToastDismissedEventArgs)
        Public Event ToastFailed(ByVal sender As Windows.UI.Notifications.ToastNotification, ByVal args As ToastFailedEventArgs)
    
        Private Sub Toast_Activated(sender As Windows.UI.Notifications.ToastNotification, args As Object) Handles Toast.Activated
            RaiseEvent ToastActivated(sender, args)
        End Sub
    
        Private Sub Toast_Dismissed(sender As Windows.UI.Notifications.ToastNotification, args As ToastDismissedEventArgs) Handles Toast.Dismissed
            RaiseEvent ToastDismissed(sender, args)
        End Sub
    
        Private Sub Toast_Failed(sender As Windows.UI.Notifications.ToastNotification, args As ToastFailedEventArgs) Handles Toast.Failed
            RaiseEvent ToastFailed(sender, args)
    
        End Sub
    
        Public Function SendToast(ByVal Title As String, ByVal Text As String) As Boolean
            Try
                Dim sbXml As New StringBuilder
                sbXml.Append("<toast launch=""Click"" >")
                sbXml.Append("<visual>")
                sbXml.Append("<binding template=""ToastGeneric"">")
                sbXml.Append("<text id=""1"">")
                sbXml.Append(Title)
                sbXml.Append("</text>")
                sbXml.Append("<text id=""2"">")
                sbXml.Append(Text)
                sbXml.Append("</text>")
                sbXml.Append("<text placement=""attribution"">Funções • Usuários</text>")
    
                sbXml.Append("</binding>")
                sbXml.Append("</visual>")
                sbXml.Append("<actions>")
                sbXml.Append("<action activationType=""background"" arguments=""OK_background"" content=""Send Background""/>")
                sbXml.Append("<action activationType=""foreground"" arguments=""OK_foreground"" content=""Send Foreground""/>")
                sbXml.Append("<action activationType=""system"" arguments=""dismiss"" content=""Close""/>")
                sbXml.Append("</actions>")
                sbXml.Append("</toast>")
    
                Dim xmlDoc As New XmlDocument()
                xmlDoc.LoadXml(sbXml.ToString)
    
                Toast = New Windows.UI.Notifications.ToastNotification(xmlDoc)
                Toast.Tag = ToastTag
                ToastNotificationManager.CreateToastNotifier().Show(Toast)
                Return True
            Catch ex As Exception
                RaiseEvent ToastError("SendToast", ex.Message)
                Return False
            End Try
        End Function
    
    End Class


    But as I had already reported the problem is that the Notification Center is not starting the Bridge process when pressed the command that in my case has the following coding:

    <action activationType="background" arguments="OK_background" content="Send Background"/>
    <action activationType="foreground" arguments="OK_foreground" content="Send Foreground"/>

    and also:

    <toast launch = "Click">

    There are no messages, just Notification Center do not start the Bridge process when it is not active.

    That is, it is not working according to the referred document that when I reported the problem:

    In the Microsoft Document (docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/toast-desktop-apps) is written:

    "For Desktop Bridge apps, just send toast notifications like a UWP app would. When the user clicks on your toast, your app will be command line launched with the launch args that you specified in the toast."

    This paragraph is no longer true after windows version 1903 update.

    You can use any Toast code with any activationtype (foreground or background), the Bridge process is not activated.

    Regards,




    • Edited by D R Mac Wednesday, October 2, 2019 5:12 PM
    Wednesday, October 2, 2019 3:40 AM
  • Hi,

    Have you tried to run your app in other devices that is also in build 1903? Does it give the same behavior?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 3, 2019 6:23 AM
    Moderator
  • Hi,

    Before upgrading my machine to version 1903, the functionality was working correctly. (according to the paragraph of the text I highlighted)

    So sorry but before upgrading another machine I have to evaluate if other features have not been affected.

    On machines with version 1803 the Bridge start functionality is working.

    Did you successfully run a Bridge process on Windows version 1903 in your lab?
    If you need, I can send you a project so you can test it.

    Regards

    • Edited by D R Mac Thursday, October 3, 2019 10:48 AM
    Thursday, October 3, 2019 10:20 AM
  • Hi,

    Sure, it will be helpful if you could offer a sample about this. Please delete other unnecessary code and just keep the notification part of the app.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, October 4, 2019 9:38 AM
    Moderator
  • Hi Roy,
    Could you give me an email address so I can submit project codes?

    Regards



    • Edited by D R Mac Monday, October 7, 2019 2:09 PM
    Friday, October 4, 2019 9:52 AM
  • Hi,

    You could share it in Github or OneDrive. Please note again that delete other unnecessary code and sensitive information. Just keep the notification part of the repro sample. 

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 8, 2019 1:48 AM
    Moderator
  • Hi Roy,

    Please see the zip module at the following link (OneDrive).

    "//1drv.ms/u/s!Arz5iPA4EMDhhwv3lnvgcc0Q9jQ4?e=4nU76k"

    To run:

    1. Extract Files
    2. Using Visual Studio 2019, Open project ...\WindowsApp\WindowsApp\WindowsApp.sln
    3. Press F5 (wait for Form1)
    4. On Form1 press Send Toast (The Toast Notification will appears)
    5. Wait for Action Center get the notification.
    6. Close Form1
    7. Open Action Center (windows+A)
    8. Press Send Foregro (the window Form1 will appears and the box Command line will show 'Command Received=>OK_foreground')
    9. Repeat steps 4 to 6. If Form1 is not running, press Windows Button and run BridgeWapProjTemplate (or edit the project and press F5 in Visual Studio 2019) to run Form1 again.
    10. Press Send Backgro (The message will be persist on Action Center - Press Windows+A)
    11. Repeat step 9, if there is no Notification in the Action Center.
    12. Press Toast Body (the window Form1 will appears and the box Command line will show 'Command Received=>Click')

    • In Windows 1903, the Steps 8 and 12 Do Not Work 
    • To run the process, press Windows Button and run BridgeWapProjTemplate (or edit the project and press F5 in Visual Studio 2019)

    Regards.


    • Edited by D R Mac Tuesday, October 8, 2019 6:21 PM
    Tuesday, October 8, 2019 12:32 PM
  • Hi,

    I'm here to update my test result. I'm sorry to that currently there is on device with build 1803 here after confirmed with many engineers. Just devices with build 1903. But I could reproduce your issue here in build 1903. I will report this issue via our internal channel to confirm the behavior on build 1803 and if this is unexpected. There might be some time delay.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 10, 2019 9:11 AM
    Moderator
  • Hi Roy,

    Thanks for update me, I hope that soon the completion of this issue will be successful.

    Cheers,


    • Edited by D R Mac Thursday, October 10, 2019 11:18 AM
    Thursday, October 10, 2019 11:17 AM
  • Hi,

    Yes, I'm also waiting for the response from the team.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, October 11, 2019 1:27 AM
    Moderator