locked
Custome notification sound is playing only if i have breakpoint windows universal 8.1

    Question

  • Hi when push notification is received i am displaying toast notification. i have issue that is if i have break point in below function then and then only custom notification sound is playing else notification sound is not playing.I thought might be audio is not loading so i added Task.delay for 2 sec/5 sec but no luck. What could be the issue.

            public static void AddTostNotification(String xmlDocument)
        {
    
           List<string> messageSection = PushNotificationHelper.GetMessageAndLandingPage(xmlDocument);
    
           ToastTemplateType toastTemplate = ToastTemplateType.ToastText01;
    
            XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
            XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
            toastTextElements[0].AppendChild(toastXml.CreateTextNode(messageSection[0]));
          //  toastTextElements[1].AppendChild(toastXml.CreateTextNode(message));
    
            IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
            ((XmlElement)toastNode).SetAttribute("launch", messageSection[1]);
    
            XmlElement audio = toastXml.CreateElement("audio");
            audio.SetAttribute("src", "ms-appx:///Assets/Guitar.wav");
    
            toastNode.AppendChild(audio);
    
            //launch tost immediatly
            ToastNotification toast = new ToastNotification(toastXml);
            ToastNotificationManager.CreateToastNotifier().Show(toast);
    
        }

    Dattatray

    Friday, March 27, 2015 4:40 AM

Answers

  • i got it, It was threading issue, have to comment below code


                //var ignored = dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                //{
     
                        PushNotificationHelper.AddTostNotification(notificationContent);
      

                //});


    Dattatray



    Friday, March 27, 2015 6:59 AM

All replies

  • i got it, It was threading issue, have to comment below code


                //var ignored = dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                //{
     
                        PushNotificationHelper.AddTostNotification(notificationContent);
      

                //});


    Dattatray



    Friday, March 27, 2015 6:59 AM
  • Hi Dattatray Deokar,

    Well Done!

    Thank you very much for sharing the solution to us.
    If you have any other questions, welcome to post it in this forum.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, April 2, 2015 4:52 AM
    Moderator