这可能是一个愚蠢的问题,但目前我真的需要帮助。有人可以帮我吗?我在我的 ReactNative 项目(Android)上实现 AppsFlyer 我想要做的是 console.log 属性参数。但是,没有 console.logging 发生。有人可以阅读我的代码段吗?我该如何访问归因参数?或者,是否有任何适当的方法来console.log属性参数或将其保存到变量?
应用程序.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);
};
})