AppsFlyerSDK / appsflyer-flutter-plugin

Flutter Plugin for AppsFlyer SDK
MIT License
142 stars 111 forks source link

onInstallConversionData payload deep link value not cleared #223

Closed keithcwk closed 1 year ago

keithcwk commented 1 year ago

Description

During the first install through a link that is intended to perform deferred deep link, the onInstallConversionData function is called, thus returning a payload as so:

appsflyerSdk.onInstallConversionData((res) {
      print(res);
       // Function to redirect to a specific page of the app
        redirect(res);
    });

{status: success, payload: {deep_link_value: /news/720254, is_first_launch: false...}}

Based on this issue, it is claimed that it is a function that will be called every time the app is invoked.

However, subsequent launches will also return the same payload as described above, the difference only being theis_first_launch boolean. This is a problem because even though i killed my android app and relaunch the app, the same payload is returned every single time, causing the deep link to be opened every single time, even if it is not the first install.

I am also aware in the ReadMe mentions that versions after 6.4 should not need me overriding the onNewIntent if my android launchMode is singleTask

To Reproduce Steps to reproduce the behavior:

  1. Uninstall the android app
  2. Click on the deferred deep link
  3. Launch the app
  4. See error

Expected behavior The deep_link_value should only be in the payload for the very first time, subsequent launches should not contain the deep_link_value

Smartphone:

pazlavi commented 1 year ago

Hi @keithcwk, Thank you for reaching out to us.

It sounds like the SDK is working as expected. This callback returns on every launch the conversion value of the install. Please Checkout our docs about deferred deep linking using onConversionDataSuccess callback here.

Please check our Unified Deep Linking option that might be a better fit for you.

If any additional help is required here, we would kindly ask you to submit a support ticket to support@appsflyer.com.

When submitting the ticket, please specify your AppsFlyer sign-up (account) email, app ID, reproduction steps, code snippets, logs, the links you used, and any additional relevant information.

keithcwk commented 1 year ago

Hi @pazlavi Thanks for the reply, I understand that it is working fine, however, I would like to suggest that apps flyer SDK will automatically remove the deep link parameter for onConversionDataSuccess because after all the whole point of it is to record first install, which means the deep link would only be used once.

Furthermore, from my findings, the deep link value seems to be 'stuck' and called to redirect for every subsequent app launches, and to prevent it from redirecting, I have to implement extra logic and error checking to prevent it from redirecting, which is not ideal.

To whoever are facing this same issue, this is the current workaround that I employed:

appsflyerSdk.onInstallConversionData((res) {
     // initialise shared preference object using riverpod
      final sharedPrefs = ref.read(sharedPrefsProvider);
      bool isFirstLaunch =
          sharedPrefs.getBool(SharedPrefsKeys.isFirstLaunch) ?? true;

      if (isFirstLaunch &&
          res['payload']['is_first_launch'] != null &&
          res['payload']['is_first_launch'] == true) {
        // Function to redirect to deep link path
        redirect(res);
        sharedPrefs.setBool(SharedPrefsKeys.isFirstLaunch, false);
      }
    });
af-do commented 1 year ago

Hi @keithcwk, The onConversionDataSuccess is the legacy callback that is used for processing deferred deeplinks, furthermore, the workaround you employ is the preferred way of handling the deeplink logic inside your application, which is also written in our DevHub, specifically step 6 of this article. In case you don't want to implement any extra logic, you can always switch to UDL.

keithcwk commented 1 year ago

Hi @af-do @pazlavi

I've read through the documentation regarding UDL, and tried implementing it as well, and I came to realised that my marketing campaigns are SRNs, which in the documentation it is mentioned the following considerations:

Considerations:

- Requires AppsFlyer Android SDK V6.1.3 or later.
- Does not support SRN campaigns.
- Does not provide af_dp in the API response.
- onAppOpenAttribution will not be called. All code should migrate to onDeepLinking.

Since my campaigns are SRNs, the UDL does not seem to pass the deep links set for my campaigns due to it being SRNs. So may I ask if you have any suggestions on how do I workaround this?

keithcwk commented 1 year ago

An update to whoever is reading this issue thread, if your marketing campaigns are SRNs, you can proceed to use both onInstallConversionData to handle deferred deep links and onAppOpenAttribution to handle regular deep links together.

Do take note to implement a logic to prevent the deferred deep link redirect to be called every app launch as mentioned earlier in this thread.

Another thing to take note is that, other SDKs that feature deep linking might cause conflict with AppsFlyer's deep link SDK, causing the deep link to not work at all. For my case, the Flutter Facebook SDK was causing my AppsFlyer deep link to not work at all.

appsflyerSdk.onInstallConversionData((res) {
   // initialise shared preference object using riverpod
      final sharedPrefs = ref.read(sharedPrefsProvider);
      bool isFirstLaunch =
          sharedPrefs.getBool(SharedPrefsKeys.isFirstLaunch) ?? true;

      if (isFirstLaunch &&
          res['payload']['is_first_launch'] != null &&
          res['payload']['is_first_launch'] == true) {
        // Function to redirect to deep link path
        redirect(res);
        sharedPrefs.setBool(SharedPrefsKeys.isFirstLaunch, false);
      }
    });