首页 > 解决方案 > 应用关闭或休眠时获取通知参数 Firebase

问题描述

当应用程序打开时,我按如下方式处理传入通知。我将操作写入参数,即单击通知后需要打开的页面的名称。

protected override void OnNewIntent(Intent intent)
{
    base.OnNewIntent(intent);
    ProcessingMessage(intent);
}
private void ProcessingMessage(Intent intent)
{
    if(null != intent)
    {
        if(null != intent.Action)
        {
            INotificationHandler notificationHandler = DependencyService.Get<INotificationHandler>();

            switch (intent.Action)
            {
                case "Re-registration": //Перерегистрация
                    notificationHandler.CallReRegistrPage();
                    break;
            }
        }
    }
}  

在此之前,我使用方法`OnMessageReceived(RemoteMessage message) 添加了所需的数据。当应用程序关闭时,这种方法自然是行不通的。当应用程序处于休眠或关闭状态时,有哪些方法可以了解发送的通知类型以及如何进一步使用它?
如何在应用程序关闭时传递参数并在单击通知后阅读它们以了解为它打开哪个页面?
这是我的后台

private Message CreateNotification(string title, string notificationBody, string token, Dictionary<string, string> Data, bool isPriority)
{
    var message = new Message()
    {
        Data = Data,
        Token = token,
        Notification = new Notification()
        {
            Body = notificationBody,
            Title = title
        }
    };

    if (isPriority)
    {
        message.Android = new AndroidConfig
        {
            TimeToLive = TimeSpan.FromHours(1),
            Priority = Priority.High
        };
    }

    return message;
}

也许在这里您可以添加一些我可以在启动应用程序时单击通知后读取的参数?
请给我一些面包屑。

标签: c#xamarin.formsxamarin.android

解决方案


推荐阅读