Can Adjust Android SDK be prevented from opening the relevant Fragment?

90 views Asked by At

I have been facing a problem related to Adjust deep links in my Android app.

I have an Adjust link in the following format: https://app.adjust.com/of6d6ty?deep_link=myapp://account/register&fallback=https://www.myapp/de/mobile-app-page

The issue I'm encountering is that when I click this Adjust link, it opens the related Fragment inside my app twice. This double navigation is causing problems for me.

The first navigation is initiated immediately by Adjust, and I am unable to interfere or stop it. After I press the back button to navigate back, the second navigation is handled by me in the onResume method of the Activity via intent.dataString, and the related Fragment opens for the second time.

I want to handle all deep links manually so that I can perform some checks before navigation, such as determining whether the user needs to log in or change their country.

I attempted to disable the relevant code blocks inside my App.kt file, which includes the following lines:

val environment = if (BuildConfig.DEBUG) AdjustConfig.ENVIRONMENT_SANDBOX else AdjustConfig.ENVIRONMENT_PRODUCTION
Adjust.onCreate(AdjustConfig(this, BuildConfig.ADJUST_APP_TOKEN, environment))
registerActivityLifecycleCallbacks(adjustListener)

The adjustListener class is defined as follows:

class AdjustLifecycleCallback : Application.ActivityLifecycleCallbacks {
    override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {}
    override fun onActivityStarted(activity: Activity) {}
    override fun onActivityResumed(activity: Activity) {
        Adjust.onResume()
    }
    override fun onActivityPaused(activity: Activity) {
        Adjust.onPause()
    }
    override fun onActivityStopped(activity: Activity) {}
    override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
    override fun onActivityDestroyed(activity: Activity) {}
}

Even when I commented out these code blocks, Adjust still opened the related Fragment again upon clicking the Adjust link.

However, I noticed that when I removed the tags from the navigation_graph.xml file, like in the following example:

<deepLink
    android:autoVerify="true"
    app:uri="myapp://account/register" />

Adjust was unable to open the related Fragment. This achieved what I wanted, preventing Adjust from opening the Fragment. However, I need these tags for certain cases within the app.

Is there any way to disable Adjust from navigating to the related Fragment without commenting out the tags? I'm looking for a solution that allows me to manually handle deep link navigation and perform necessary checks while still using the tags when needed.

0

There are 0 answers