react-native-get-phone-number
v0.1.0
Published
A lightweight Expo native module for Android that retrieves the device's phone number.
Maintainers
Readme
react-native-get-phone-number
A React Native module (Android only) to retrieve the device’s phone number. This module is intended for use in Expo projects
Overview
react-native-get-phone-number provides a simple method to retrieve the device’s phone number on Android devices.
Note: This feature is not available on iOS.
Installation
You can install this package using one of the following package managers:
npm install react-native-get-phone-numberOr:
yarn add react-native-get-phone-number
pnpm add react-native-get-phone-number
bun add react-native-get-phone-numberPermissions
To access the phone number on Android, your application needs the following permissions in its Android manifest:
android.permission.READ_PHONE_STATEandroid.permission.READ_PHONE_NUMBERSandroid.permission.READ_SMS
Usage
Once the permissions are correctly set in your application, you can call the module as follows:
import { getPhoneNumber } from "react-native-get-phone-number";
// Inside an async function
const phoneNumber = await getPhoneNumber();Note: On some devices, the phone number may be null or unavailable if the SIM card does not allow direct access or if the network operator does not store it on the SIM.
