与 pin screen 和 firebase 推送通知的深度链接

问题描述

我的目标:我想向用户发送推送通知。当用户点击该通知时,用户应导航到名为 HitoryDe​​tailsFragment 的特定片段。

我所做的:我实现了 FirebaseInstanceIdService 和 FirebaseMessagingService,并且能够捕获从后端服务器发送的 Firebase 消息。我通过“隐式深层链接”实现了深层链接。我使用嵌套导航图实现了导航。与历史相关的屏幕放置在单独的导航图 graph_history.xml 中。

问题是什么:当应用程序打开时,一切正常。我点击通知 -> 我被重定向到 HistoryDe​​tailFragment,当我按下后退按钮时,它会返回到 HistoryListFragment。但是当应用程序关闭时(不在最近的应用程序托盘中),而不是 HistoryDe​​tailsFragment,SplashFragment 被打开,之后我被重定向到 HomeFragment(这是正确的,因为这就是流程应该如何工作)。但是,当应用程序关闭时,如何将用户重定向到 HistoryDe​​tails?此外,我应该显示一个 Pin 屏幕,用户应该在其中输入他的 pin,如果他之前没有,在显示 HistoryDe​​tailsFragment 之前。

我的代码如下。

private fun createPendingIntent(history: History?) = NavDeepLinkBuilder(this).run {
    setGraph(R.navigation.graph_main)
    history?.let {
        //todo when the app is not open (not in tray of recent apps),this destination does not work
        //this instead navigates to SplashFragment
        //which is correct,because we have not entered the pin,so we are not entitled to open the history detail screen
        //but how do I handle this case?
        setDestination(if (it.type.isNews) R.id.nav_history_news else R.id.nav_history_detail)
        setArguments(if (it.type.isNews) HistoryNewsFragmentArgs(it.link).toBundle() else HistoryDetailFragmentArgs(it.id).toBundle())
    }
    createPendingIntent()
}

主导航图:

enter image description here

历史图表:

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...