Hi

C# Code to Capture Phone Link Notifications

 using System;

using System.Linq;

using System.Threading.Tasks;

using Windows.UI.Notifications.Management;

using Windows.UI.Notifications;


namespace PhoneLinkReader

{

    class Program

    {

        static async Task Main(string[] args)

        {

            var listener = UserNotificationListener.Current;

            await listener.RequestAccessAsync(); // Request notification access


            var notifications = await listener.GetNotificationsAsync(NotificationKinds.Toast);

            

            foreach (var notification in notifications)

            {

                string appName = notification.AppInfo.DisplayInfo.DisplayName;

                

                if (appName.Contains("Phone Link") || appName.Contains("Your Phone"))

                {

                    string message = notification.Notification.Visual.GetBinding(KnownNotificationBindings.ToastGeneric)

                                      ?.GetTextElements()

                                      ?.FirstOrDefault()

                                      ?.Text;


                    Console.WriteLine($"📩 Message from Phone Link: {message}");

                }

            }

        }

    }

}


Previous
Next Post »