c# - 如何从 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;
}
我找不到如何重新制作它的方法。
感谢您的任何帮助。
解决方案
推荐阅读
- python - 在python中转义ascii响铃字符
- django - 我对 Django Admin 有疑问。画面被分割
- jvm - 内存不足后的 Oracle 协议冲突
- mysql - Laravel mysql查询返回通知
- javascript - Spotify Web API 节点 - 未提供令牌错误
- python - sklearn PLSregression n_elements 是什么意思?
- html - Inline-Flex 元素之间出现异常的“空白”
- server - 数百个 /usr/sbin/apache2 -k start 进程是否会从端口 80 到 3000 杀死我的站点代理?
- c - CS50 pset5 Speller [2021] - “ :( 程序没有内存错误”
- python - 在 Python 乘法方面需要帮助