This might be a dumb question, but currently I really need a help. Can someone please help me out? I'm implementing AppsFlyer on my ReactNative Project (Android) What I want to do is console.log attribution parameter. But, there are no console.logging happening. Could someone please read my snippet and how can I access to attribution parameter, please? or, is there any proper way to console.log attribution parameter or save it to variable?
App.tsx
import appsFlyer from 'react-native-appsflyer';
var testFunc = appsFlyer.onAppOpenAttribution(
(data) => {
console.log(data);
}
);
appsFlyer.initSdk(
{
devKey: '***************************',
isDebug: false,
},
(result) => {
console.log(result);
},
(error) => {
console.error(error);
},
);
const Home: React.FC<Props> = props => {
const [appState, setAppState] = useState(AppState.currentState);
// ! when I press device's home button (appstate changes to background),
// ! console.log in testFunc is not working...
useEffect(() => {
function handleAppStateChange(nextAppState) {
if (appState.match(/active|foreground/) && nextAppState === 'background') {
if (testFunc) {
testFunc();
testFunc = null;
}
}
setAppState(nextAppState);
}
AppState.addEventListener('change', handleAppStateChange);
return () => {
AppState.removeEventListener('change', handleAppStateChange);
};
})
To my understanding, the
onAppOpenAttribution
event only triggers when you already have the app installed and click on a deep link. Try to useonInstallConversionData
instead and see what happens, since it triggers once the SDK is initialized. I'd also remove the "useEffect" section entirely just to test. I hope this helps.