Javascript 无法读取属性';initSdk';未定义的属性-Appsflyer集成反应本机
我试图在react本机应用程序中实现AppsFlyer,但出现以下错误“无法读取未定义的属性'initSdk'” 我导入了本地appsflyerJavascript 无法读取属性';initSdk';未定义的属性-Appsflyer集成反应本机,javascript,reactjs,react-native,appsflyer,Javascript,Reactjs,React Native,Appsflyer,我试图在react本机应用程序中实现AppsFlyer,但出现以下错误“无法读取未定义的属性'initSdk'” 我导入了本地appsflyer import React, { Component } from 'react'; import { Alert, Platform, AppRegistry, NetInfo, Text, } from 'react-native'; //... import appsFlyer from 'react-native-appsflyer'
import React, { Component } from 'react';
import {
Alert,
Platform,
AppRegistry,
NetInfo,
Text,
} from 'react-native';
//...
import appsFlyer from 'react-native-appsflyer';
//...
并尝试调用initSdk方法
export default class App extends Component {
initSdk(){
console.log('allo appsflyer');
let options = {
devKey: 'AF_DEV_KEY',
appId: "IOS_APP_ID",
isDebug: true
};
appsFlyer.initSdk(options,
(result) => {
this.setState( { ...this.state, initSdkResponse: result });
console.log(initSdkResponse);
},
(error) => {
console.error(error);
}
)
}
并在我的startApp函数中启动了它
startApp(root) {
this.initSdk();
console.log('app store update --> root', root);
switch (root) {
//...
}
}
}
有人来帮我吗?如果本机依赖项链接不正确,可能会发生此错误。如果从项目根目录(对于Android本机依赖项)运行
react native link react native appsflyer
,并为iOS添加相关的Pod依赖项,则应解决此问题:
将appsFlyerFramework添加到Podfile并运行pod安装。
例如:
(假设您的pod文件位于iOS目录中)
运行pod安装
如果您不使用CoCoapod,您可以按照手册中的集成说明进行操作:我偶尔也会遇到这种情况,这非常烦人且不一致。我认为这与appsflyer的react本机模块在应用程序构建时未正确集成有关。是的,我从头开始重新安装了appsflyer模块,并且该模块正常工作
pod 'react-native-appsflyer',
:path => '../node_modules/react-native-appsflyer'