>我创建了用户将任务分配给其他用户的应用程序,当用户分配任务时,其他用户使用收到通知,您已分配新任务这是我的代码
public void NewTaskNotification()
{
try
{
var result = "-1";
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://fcm.googleapis.com/fcm/send");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Headers.Add(string.Format("Authorization: key={0}", "AAAAHiXg3GM:APA91bFhpVU5meuhVtbHUzIgd7Ualwdi8PROKbXIf0Y_tU9sxI71vPdiInOpRgribAUuqpuqn5hmaZV7ZwQTGv2KKERsKGYOwjkwZIqssWYiYNh7IrjhfnBR0XJj7t-GW7GqvEHVs0Q"));
httpWebRequest.Headers.Add(string.Format("Sender: id={0}", "129484512355"));
httpWebRequest.Method = "POST";
var payload = new
{
to = device_token.Text,
priority = "high",
content_available = true,
notification = new
{
body = "You have been assigned a new task " + "(" + TaskName.Text + ") by " + EmployeeName.Text,
title = "New Task",
icon = "Icon.png"
},
data = new
{
open_page = "NewTask",
new_task="newNotification",
},
};
应用.cs
protected override void OnStart()
{
CrossFirebasePushNotification.Current.OnNotificationOpened += (s, p) =>
{
if (p.Data["open_page"].ToString() == "NewTask")
{
//var mdMasterPage = new MainPage { Title = "master page" };
//var mdp = new MasterDetailPage();
//mdp.Master = mdMasterPage;
//mdp.Detail = new NavigationPage((Page)Activator.CreateInstance(typeof(ToDo)));
//Application.Current.MainPage = mdp;
MainPage = new NavigationPage(new TabbedMainPage())
{
BarBackgroundColor = Color.FromHex("#C6488D"),
BarTextColor = Color.White
};
}
目前,当我打开通知时,它只是打开页面,不要点击链接到此通知的列表视图的特定行,我需要解决这个问题,但我被困住了如何做到这一点
您可以使用方法ScrollTo
.
在文档中,您可以指定要滚动到的项目。