AppsFlyerSDK / appsflyer-react-native-plugin

AppsFlyer plugin for React Native
MIT License
273 stars 196 forks source link

onInstallConversionData callback doesn't trigger if ATT is enabled? #286

Closed gtsec closed 1 year ago

gtsec commented 3 years ago

Report

Plugin Version

6.2.42

On what Platform are you having the issue?

iOS

What did you do?

In my iOS settings, I have ATT disabled. I rely on appsFlyer.onInstallConversionData(res => ...) being fired so I can then unhide the main contents of the app.

What did you expect to happen?

onInstallConversionData to have its callback called.

What happened instead?

It never called. I think maybe on killing and reopening the app it did?

Please provide any other relevant information.

I expected source to be either success or failure, instead of not getting a reply. Even with ATT off, I would still expect the callback to fire.

Also, maybe appsFlyer.stop()being run at some earlier time had somehow interfered and caused this issue.


I have stopped relying on the callback firing in order to satisfy some condition in my code, so instead I use requestTrackingStatus() to let me know a user has disabled ATT altogether and fulfilled the conditions for my app to work.

amit-kremer93 commented 3 years ago

Hi @gtsec and thank you for opening this issue. appsFlyer.onInstallConversionData is not related to the ATT and it will fire only after appsFlyer.init sends a launch. it can be delayed if you set number in the timeToWaitForATTUserAuthorization field like here

gtsec commented 3 years ago

My problem is different now, basically there is a scenario where:

  1. User has my app already installed, ATT is disabled
  2. User now enables ATT, opens app
  3. In the following code, appsFlyer.onInstallConversionData(res => ... does not trigger again after user presses Allow when seeing the ATT prompt
appsFlyer.initSdk(
  {
    devKey: env.APPSFLYER_DEV_KEY,
    isDebug: env.IS_PRODUCTION == 'false',
    appId: env.APPSFLYER_APP_ID,
    onInstallConversionDataListener: true, // Optional
    onDeepLinkListener: true, // Optional
    timeToWaitForATTUserAuthorization: 10, // for iOS 14.5
  })

const App = () => {

  // some other code...

  useEffect(() => {
    let onInstallConversionDataCanceller = null // appsFlyer.onInstallConversionData(res => dispatch(setInstallationConversionData(res)))

    requestTrackingPermission().then(trackingStatus => {
      if (
        trackingStatus !== 'authorized' &&
        trackingStatus !== 'unavailable'
      ) {
        appsFlyer.stop(true)
        dispatch(setInstallationConversionStatus('failure'))
      } else { // user has suddenly allowed it
        onInstallConversionDataCanceller = appsFlyer.onInstallConversionData(res => {
          dispatch(setInstallationConversionData(res))
        })
      }
      dispatch(setTrackingStatus(trackingStatus))
    })

    appsFlyer.getAppsFlyerUID((err, appsFlyerUID) => {
      if (err) {
        console.error('appsFlyer.getAppsFlyerUID error:', err);
      } else {
        dispatch(setAppsFlyerId(appsFlyerUID))
      }
    })

    return () => {
      onInstallConversionDataCanceller && onInstallConversionDataCanceller()
    }
  }, [])
amit-kremer93 commented 3 years ago

Hi @gtsec. according to this, you must set the appsFlyer.stop to false if you want to trigger appsFlyer.onInstallConversionData again

gtsec commented 3 years ago

I'm experiencing this issue now regardless, on XCode + iOS Simulator at least. This is a bit of a pain and I have no idea why the callback doesn't call. It would be way, way better if the callback finishes no matter what, or at least throw some sort of error! Otherwise its just very difficult to figure out what I might have done wrong.

gtsec commented 3 years ago

Here's the code I had: AppsFlyer version = 6.26 XCode 12.5, but also not working for someone else on 12.4

I've attempted putting appsFlyer.onInstallConversionData(res => { ... }) at the very top of App.tsx, before I call appsFlyer.initSdk(), but the callback still never fires.... why?

amit-kremer93 commented 1 year ago

This is issue is closed due to inactivity. Contact our support team if the issue has not been solved