I use Navigation Component. I have app with 2 main parts: 1 splash activity with it's nav_graph 2 main activity with bottom navigation where every menu item has its own nav_graph. The problem is that i cant figure out how to do navigation when notification pops up.
So when notification arrived and user clicked on it, i need: - check if app is open and what screen is open now - if app is closed or in background, through deep link, check at splash activity: if user is logged in - move to main activity (if not provide auth screen) keep navigation on deep link to fragment I need.
Splash graph and one of three memu items graphs
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/splash_graph"
app:startDestination="@id/splashFragment">
<fragment android:id="@+id/splashFragment"
android:name="com.app.app.ui.navigation.fragment.SplashFragment"
android:label="SplashFragment">
<action android:id="@+id/action_splashFragment_to_authFragment"
app:popUpTo="@+id/authFragment"
app:popUpToInclusive="true"
app:destination="@id/authFragment"/>
<action android:id="@+id/action_splashFragment_to_mainActivity"
app:popUpTo="@+id/mainActivity"
app:popUpToInclusive="true"
app:destination="@id/mainActivity" app:launchSingleTop="true"/>
</fragment>
<fragment android:id="@+id/authFragment"
android:name="com.app.app.ui.navigation.fragment.AuthFragment"
android:label="AuthFragment">
<action android:id="@+id/action_authFragment_to_mainActivity"
app:popUpTo="@+id/mainActivity"
app:popUpToInclusive="true"
app:destination="@id/mainActivity" app:launchSingleTop="true"/>
</fragment>
<activity android:id="@+id/mainActivity"
android:name="com.app.app.ui.navigation.activity.MainActivity"
android:label="MainActivity">
<deepLink android:id="@+id/deepLinkMain" app:uri="com.app.app/"/>
</activity>
</navigation>```
``` <navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nextFragment"
app:startDestination="@id/nxtFragment">
<fragment android:id="@+id/nxtFragment"
android:name="com.app.app.ui.navigation.fragment.NextFragment"
android:label="Next">
<deepLink
android:id="@+id/deepLink"
app:uri="com.app.app/nextFragment{id}"
android:autoVerify="true"/>
<argument
android:name="id"
app:argType="string"/>
</fragment>
</navigation>```
from Deep linking with splash screen and login state
No comments:
Post a Comment