Skip to content

witPranav/react-native-phone-number

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
      }
});

About

Request Phone Number on Android

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published