首页 > 解决方案 > 如何从 Current_NotificationTapped 事件返回值(本地推送通知)

问题描述

我正在使用 Plugin.LocalNotification 来获取本地推送通知。

每个通知在ReturningData参数中都有一个数字,当收到时,我想从方法中返回数字ReceiveNotification()以供进一步使用。

通知是这样构建的:

var notif = new NotificationRequest
            {
                BadgeNumber = 1,
                Description = "New Message To Send (id " + id + " )",
                Title = "Message Server",
                ReturningData = Convert.ToString(id)
            };

接收时触发的方法:

 public int ReceiveNotification()
        {
            int idmessage = NotificationCenter.Current.NotificationTapped += Current_NotificationTapped; 
               // line above shows an error because it cant return int
            return idmessage;
            
        }

        private int Current_NotificationTapped(NotificationTappedEventArgs e)
        {
            int idMessage = Int32.Parse(e.Request.ReturningData);
            return idMessage;
        }

我找不到如何重新制作它的方法。

感谢您的任何帮助。

标签: c#push-notification

解决方案


推荐阅读