AppsFlyerSDK / appsflyer-android-sdk

AppsFlyer Android SDK
Other
9 stars 2 forks source link

`onDeepLinking` callback does not work when the deep-link is triggered from within app. #59

Closed sahil-banknovo closed 1 year ago

sahil-banknovo commented 1 year ago

We have encountered an issue with deep link handling in our app.

 SDK Version : com.appsflyer:af-android-sdk:6.12.1

ISSUE: The problem is that the deep link listener onDeepLinking callback does not get triggered when the app is in the foreground. Specifically, when a deep link is triggered from within the app(using InApp messaging actions) while it's in the foreground, the SDK's DeepLinkListener callback is not working.

We have observed that the deep link listener callback works correctly only when we put the app into the background and then bring it back to the foreground. It seems that triggering this callback requires putting the app into the background at least once after trigger of a deep link.


below are the code snippet calling init and start this in onCreate of Application Class and subscribeDeepLinkListener tried to put this code with both Application/Activity class and its not working in both cases.

AppsFlyer Init

AppsFlyerLib.getInstance().init(getDevKey(), null, context)

AppsFlyer Start

`
AppsFlyerLib.getInstance().start(context, getDevKey(), object : AppsFlyerRequestListener {

  override fun onSuccess() {
    LogUtil.d(LOG_TAG, "Launch sent successfully")
  }

  override fun onError(errorCode: Int, errorDesc: String) {
    LogUtil.d(LOG_TAG, "Launch failed to be sent:\n" +
        "Error code: " + errorCode + "\n"
        + "Error description: " + errorDesc)
  }

})

AppsFlyerLib.getInstance().setDebugLog(BuildConfig.DEBUG)

`

Apps Flyer Subscribe for deeplink

` AppsFlyerLib.getInstance().subscribeForDeepLink(DeepLinkListener { deepLinkResult ->

  when (deepLinkResult.status) {
    DeepLinkResult.Status.FOUND -> {
      LogUtil.d(LOG_TAG, "Deep link found")
      deepLinkObj = deepLinkResult.deepLink
      listener()
    }

    DeepLinkResult.Status.NOT_FOUND -> {
      LogUtil.d(LOG_TAG, "Deep link not found")
      return@DeepLinkListener
    }

    else -> {
      // dlStatus == DeepLinkResult.Status.ERROR
      val dlError = deepLinkResult.error
      LogUtil.d(LOG_TAG, "There was an error getting Deep Link data: $dlError")
      return@DeepLinkListener
    }

  }
  try {
    LogUtil.d(LOG_TAG, "The DeepLink data is: $deepLinkObj")
    return@DeepLinkListener
  } catch (e: Exception) {
    LogUtil.d(LOG_TAG, "DeepLink data came back null")
    return@DeepLinkListener
  }

})
`
github-actions[bot] commented 1 year ago

👋 Hi @sahil-banknovo and Thank you for reaching out to us. In order for us to provide optimal support, please submit a ticket to our support team at support@appsflyer.com. When submitting the ticket, please specify:

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.

StevenRogers commented 5 months ago

Hi, I also encountered the same problem. Did you find a solution and prevent it?

DawnNguyenAhiho commented 3 months ago

Hi @sahil-banknovo, I'm facing this problem too. It work well on Android 12 and below. But on Android 13 and Android 14, the onDeepLinking is not triggered at all. I'm using version 6.15.0

sahil-banknovo commented 3 months ago

@DawnNguyenAhiho You can manually call the function below in your activity to check whether it was opened from a deep link. If the intent was opened through a deep link, it will automatically trigger the onDeepLinking() function.

AppsFlyerLib.getInstance().performOnDeepLinking(intent, context) after calling this function its get triggered at my end.

Reference link : https://dev.appsflyer.com/hc/docs/android-sdk-reference-appsflyerlib#performondeeplinking

DawnNguyenAhiho commented 3 months ago

Thank @sahil-banknovo, I'm already use this function, but it never go into onDeepLinking. The log tell me that there is the intent contain deeplink (with action View and extras is deeplink from AppsFlyer), but there is no log in onDeepLinking function

oguzhanaslann commented 1 month ago

I applied @sahil-banknovo solution, works as expected. But, AppsFlyer team should really examine the issue.