AppsFlyerSDK / appsflyer-react-native-plugin

AppsFlyer plugin for React Native
MIT License
284 stars 202 forks source link

`manualStart` option still requires onDeepLink to be set before `initSdk` #574

Open MoritzCooks opened 2 months ago

MoritzCooks commented 2 months ago

Report

Plugin Version

6.12.2

On what Platform are you having the issue?

iOS (probably also Android)

What did you do?

Tried to subsequently register a deeplink handler between initSdk and startSdk with manualStart option set to true

What did you expect to happen?

I would have expected the appyFlyer SDK to allow me adding the deeplink listener subsquently so that the deeplinkHandler gets fired only after the SDK got started through appsFlyer.startSdk()

What happened instead?

Once the app is fully closed and we try to open a deeplink, we see the SendingonDeepLinkingwith no listeners registered warning appearing.

Please provide any other relevant information.

We are using react-navigation with linking for deeplinking. To be able to get access to the navigation/linking, the appsFlyer init has to be placed within the <NavigationContainer>. The complexity exists because we want to send an AppStart event once the app has been launched and the App.tsx got executed. To be able to do that, the appsFlyer.initSdk() has to be executed before the first appsFlyer.logEvent() gets fired.

I would expect the onDeepLink to work the same way so that it's possible to run initSdk, set an onDeepLink listener and then finally startSDK once everything is ready.

Example pseudo-code:

// App.tsx
// ...
appsFlyer.initSdk()

appsFlyer.logEvent("AppStart")

return (
  <RandomProvider>
    <RootNavigator />
  </RandomProvider>
)
// RootNavigator.tsx
// ...
const navigationRef = useNavigationContainerRef()

return (
  <NavigationContainer
    ref={navigationRef}
    onReady={() => {
      appsFlyer.onDeepLink = ({ data }) => {
        // using navigation to navigate around 
        navigationRef.current.navigate(data["deep_link_value"])
      }
      appsFlyer.startSdk()
    }}
    linking={linkingConfig}
  >
    {/* screens to navigate to go here */}
  </NavigationContainer>
)