在 React Native 中打开通讯录应用 [英] Opening Contacts app in react native

查看:59
本文介绍了在 React Native 中打开通讯录应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个本机应用程序,在一个屏幕中有一个表格,用户必须填写表格,用户必须填写他的手机号码,所以我制作了一个按钮,可以打开联系人应用程序用户电话,用户可以从该列表中选择联系人号码,该号码将填入该字段.

I am making a react native app and in one screen there is a form in which user has to fill the form in which the user has to fill his mobile number so I am making a button which will open the contacts app of the user phone and the user can select the conatct number from that list and that number gets filled in the field .

我找到了这个链接 react-native-contacts 但我认为它是获取所有联系人列表并使用列表视图将其显示在本机应用程序中,但我不想要这种类型的功能.我只想打开联系人应用程序,然后如果用户选择应在手机号码字段中填写的任何特定联系人.

I found this link react-native-contacts but i think that it is taking all the contact Lists and displaying it in the react native app using List View but I do not want this type of functionality . I only want to open the contacts app and then if the user select any particular contact that should be filled in the mobile number field.

代码实现

import ContactsWrapper from 'react-native-contacts-wrapper';
import { Separator, SeparatorDate } from '../../components/List';

export default class AddNewClub extends Component {


  constructor(props) {

    super(props);
    this.onMobileIconPressed = this.onMobileIconPressed.bind(this);

    this.state = {

      registerButtonClicked: false,


    };

  }

  registerButtonClick = () => {


    this.setState({
      registerButtonClicked: true,

    });

  };


  onMobileIconPressed() {
    ContactsWrapper.getContact()
    .then((contact) => {
        // Replace this code
        console.log(contact);
    })
    .catch((error) => {
        console.log("ERROR CODE: ", error.code);
        console.log("ERROR MESSAGE: ", error.message);
    });
}

这是我写的代码,当我在设备上测试这个屏幕时,它给出了一个错误无法解析模块 react-native-contacts-wrapper

This is the code which I have written and when I am testing this screen on device then it gives an error "unable to resolve module react-native-contacts-wrapper

推荐答案

我遇到了同样的情况,但我没有找到任何可以打开本机联系人列表的包,因此,我制作了一个屏幕,我可以在其中获取所有联系人列表视图.

I had the same scenario but I didn't find any package which can open native contact list, therefore, I made a screen where I am getting all contacts in ListView.

这篇关于在 React Native 中打开通讯录应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆