1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- /**
- * Sample React Native App
- * https://github.com/facebook/react-native
- *
- * @format
- * @flow
- */
- import React, {Component} from 'react';
- import {
- AppRegistry,
- StyleSheet,
- Text,
- View,
- Platform
- } from 'react-native';
- import ContactPickerBridge from 'react-native-contacts-picker';
- import checkContactsPermission from './requestPermission';
- import kiperContacts from 'react-native-kiper-contacts';
- if(Platform.OS==='android'){
- checkContactsPermission()
- }
- export default class ContactPicker extends Component {
- render() {
- return (
- <View style={styles.container}>
- <Text style={styles.welcome} onPress={this.openContactPicker}>打开通讯录选择器</Text>
- <Text style={styles.welcome} onPress={this.getAllContact}>获取全部通讯录</Text>
- <Text style={styles.welcome} onPress={this.checkContactPermissions}>是否有通讯录权限</Text>
- </View>
- );
- }
- openContactPicker = () => {
- ContactPickerBridge.openContactPicker((result) => {
- console.log('openContactPicker ---->', JSON.stringify(result));
- });
- };
- getAllContact = () => {
- ContactPickerBridge
- .getAllContact((result) => {
- console.log('getAllContact ---->', JSON.stringify(result));
- });
- };
- checkContactPermissions = () => {
- ContactPickerBridge
- .checkContactPermissions((result) => {
- console.log('getAllContact ---->', JSON.stringify(result));
- });
- };
- }
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#F5FCFF',
- },
- welcome: {
- fontSize: 20,
- textAlign: 'center',
- margin: 10,
- },
- instructions: {
- textAlign: 'center',
- color: '#333333',
- marginBottom: 5,
- },
- });
|