我有下一个目标:我的应用程序接收推送通知 (FCM),我需要在所有可能的情况下处理用户操作。
- 当我收到前台推送并在WillPresentNotification中处理它时- 一切都按预期工作。
当我将应用程序发送到后台模式(单击主页按钮)并接收推送时,在通知中心单击该推送我在DidReceiveNotificationResponse方法中有下一个代码:
MessagingCenter.Send<object, PushNotificationObject>(this, "PushNavigationToRootPage", push);
所以它只是向 RootPage 发送一条消息,该消息被订阅/取消订阅,如下所示:
protected override void OnAppearing()
{
base.OnAppearing();
MessagingCenter.Unsubscribe<object, PushNotificationObject>(this, "PushNavigationToRootPage");
MessagingCenter.Subscribe<object, PushNotificationObject>(this, "PushNavigationToRootPage", (sender, _push) => { ... });
}
protected override void OnDisappearing()
{
MessagingCenter.Unsubscribe<object, PushNotificationObject>(this, "PushNavigationToRootPage");
base.OnDisappearing();
}
enter code here
它也有效!但!
- 如果我完全关闭应用程序(从 App Switcher 将其刷掉)然后单击收到的推送 - 它只会发送一条消息(来自上面的代码),但永远不会到达放置在 RootPage 的订阅内的代码。
有什么错误的想法吗?
提前致谢!