react-native-phone-number

1.0.1 • Public • Published

react-native-phone-number

Getting started

$ npm install react-native-phone-number --save

Note

  • This module works only for android at the moment.

How it works

-- This module provides 2 methods both of which provide a native overlay from which the user can select a phone number.

Usage

  • Goto app level build.gradle in android/app/build.gradle and add the following dependency.
dependencies {
    ...
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    implementation "com.google.android.gms:play-services-auth:20.2.0" // Add this line
    }
import PhoneNumber from 'react-native-phone-number';
    
// Get status constants from the module
const {STATUS_CANCELLED, STATUS_ERROR, STATUS_SUCCESS} = PhoneNumber.getConstants();

// Recommended method for obtaining the phone number
PhoneNumber.requestPhoneNumber((res) => {
      if(res.status === STATUS_SUCCESS){
        //process res.data
      }else if(res.status === STATUS_CANCELLED){
        //handle cancel res.data
      }else if(res.status === STATUS_ERROR){
        //handle error res.data
      }
});

// Deprecated method for obtaining the phone number
PhoneNumber.hintRequestPhoneNumber((res) => {
      if(res.status === STATUS_SUCCESS){
        //process res.data
      }else if(res.status === STATUS_CANCELLED){
        //handle cancel res.data
      }else if(res.status === STATUS_ERROR){
        //handle error res.data
      }
});

Package Sidebar

Install

npm i react-native-phone-number

Weekly Downloads

10

Version

1.0.1

License

MIT

Unpacked Size

14.6 kB

Total Files

10

Last publish

Collaborators

  • witpranav