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

ShowPresenceNotification() public static method

public static ShowPresenceNotification ( string name, string imageUri, bool isOnline ) : void
name string
imageUri string
isOnline bool
return void
        public static void ShowPresenceNotification(string name, string imageUri, bool isOnline)
        {
            var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText02);

            // Set Text
            var toastTextElements = toastXml.GetElementsByTagName("text");
            toastTextElements[0].AppendChild(toastXml.CreateTextNode(name));
            toastTextElements[1].AppendChild(toastXml.CreateTextNode(isOnline ? "is now Online" : "is now Offline"));

            // 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");

            ShowNotification(toastXml);
        }