我努力了
yarn add react-native-contacts
07000
但它给出错误
undefined is not an object(evaluating Contacts.getAll).
谢谢
STEP-1. yarn add react-native-contacts –save
STEP-2. react-native link react-native-contacts
STEP_3. Add following code manually in the files mentioned:
AndroidManifest.xml中
添加以下权限: –
<uses-permission android:name="android.permission.READ_PROFILE" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" />
MainApplication.java
import com.rt2zz.reactnativecontacts.ReactNativeContacts; //import this package protected List<ReactPackage> getPackages() { mCallbackManager = new CallbackManager.Factory().create(); return Arrays.<ReactPackage>asList( new ReactNativeContacts() // Add this ); }
安卓/ settings.gradle
include ':react-native-contacts' project(':react-native-contacts').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-contacts/android')
Android设备/应用/的build.gradle
在依赖项块中添加以下内容: –
compile project(':react-native-contacts')
注意: – 如果您不使用纱线,也可以使用npm进行安装
例如:-
> npm install react-native-contacts> react-native link react-native-contacts