React-native-contacts: Cannot read property "getAll" of undefined (local mac os x)

Created on 26 Dec 2016  路  17Comments  路  Source: morenoh149/react-native-contacts

Hi I am running my react-native app on my local machine with iOS simulator. I have followed all of the instructions in the ReadMe here. But when I call the code snippet, I get the error:

"Cannot read property "getAll" of undefined"

Most helpful comment

You also need to rebuild your project by running react-native run-android or run-ios.

Was a victim of this.

All 17 comments

Sounds like you have an issue properly initializing the module. Please share code here.

I think this error is often caused by linking problems.

@morenoh149

var Contacts = require('react-native-contacts');

class ImportContactScreen extends React.Component {

  _pressRow(){
    Contacts.getAll((err, contacts) => {
      if(err && err.type === 'permissionDenied'){
        // x.x
      } else {
        console.log(contacts)
      }
    });
  }

render() {
    return (
      <View
        style={styles.container}>
        <StatusBar barStyle="default" />
        <View style={styles.header}>
          <Text style={styles.h1}>{"Hi, " + {this.props.name}. + "Let's import your contacts:"}</Text>
        </View>
        <View style={[styles.section, styles.last]}>
          <F8Button
            style={styles.button}
            onPress={() => this._pressRow()}
            caption="Import"
          />
        </View>
      </View>
    );
  }

I had the same problem, double check you followed the installation instructions. Specially this problems is due to missing library on the build phases of the project. (step 3 on ios installation)

You also need to rebuild your project by running react-native run-android or run-ios.

Was a victim of this.

I still encounter this problem , I trid all the way above,but nothing works ,Anyone can help me ? tkx

well, i solved by follow:

  1. In XCode, in the project navigator, right click Libraries Add Files to [your project's name]
  2. add ./node_modules/react-native-contacts/ios/RCTContacts.xcodeproj
  3. In the XCode project navigator, select your project, select the Build Phases tab and in the Link Binary With Libraries section add libRCTContacts.a

in https://github.com/rt2zz/react-native-contacts

I still encounter this problem , I trid all the way above,but nothing works ,Anyone can help me ? tkx

try like me ....

i have the same problem.i will try these ways

@challengerST let us know if it works

+1

I've revised the readme to be more clear. This is an installation issue.

I have to delete the ios folder and build again using react-native eject and then use the react-native link

interesting, I've abandoned react-native link, it never worked for me.

I do not know what the problem is but some dependence does not work other, other I need to add manual

I've heard react-native link will update podfile if you use that. That may be part of it.

I have not had a very good experience with podfile, if it is to use podfile I would rather add manual myself.

Was this page helpful?
0 / 5 - 0 ratings