ChatterBox.Client.Common.Notifications.ToastNotificationService.ShowInstantMessageNotification C# (CSharp) Method

ShowInstantMessageNotification() public static method

public static ShowInstantMessageNotification ( string fromName, string fromUserId, string imageUri, string message ) : void
fromName string
fromUserId string
imageUri string
message string
return void
        public static void ShowInstantMessageNotification(string fromName, string fromUserId, string imageUri, string message)
        {
            var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText02);

            // Set Text
            var toastTextElements = toastXml.GetElementsByTagName("text");
            toastTextElements[0].AppendChild(toastXml.CreateTextNode(fromName));
            toastTextElements[1].AppendChild(toastXml.CreateTextNode(message));

            // Set image
            var toastImageAttribute = toastXml.GetElementsByTagName("image").Select(s => ((XmlElement) s)).First();
            toastImageAttribute.SetAttribute("src", imageUri);
            toastImageAttribute.SetAttribute("alt", "logo");

            // toast duration
            var toastNode = toastXml.SelectSingleNode("/toast");
            var xmlElement = (XmlElement) toastNode;
            xmlElement?.SetAttribute("duration", "short");

            ToastNotificationLaunchArguments args = new ToastNotificationLaunchArguments(NotificationType.InstantMessage);
            args.arguments.Add(ArgumentType.FromId, fromUserId);

            xmlElement?.SetAttribute("launch", args.ToXmlString());

            ShowNotification(toastXml);
        }