expo-cellular
Version: 55.0.6
Provides information about the user’s cellular service provider, such as carrier name and country.
Installation
npx expo install expo-cellular
Usage
import * as Cellular from 'expo-cellular';
const carrier = await Cellular.getCarrierNameAsync();
const isoCountryCode = await Cellular.getIsoCountryCodeAsync();
const mobileCountryCode = await Cellular.getMobileCountryCodeAsync();
console.log('Carrier:', carrier);
console.log('Country:', isoCountryCode);
API Reference
Methods
Cellular.getCarrierNameAsync()
() => Promise<string | null>
Gets the carrier/network operator nameconst carrier = await Cellular.getCarrierNameAsync();
console.log(carrier); // "Verizon", "T-Mobile", etc.
Cellular.getIsoCountryCodeAsync()
() => Promise<string | null>
Gets the ISO country codeconst country = await Cellular.getIsoCountryCodeAsync();
console.log(country); // "us", "gb", "jp", etc.
Cellular.getMobileCountryCodeAsync()
() => Promise<string | null>
Gets the mobile country code (MCC)
Cellular.getMobileNetworkCodeAsync()
() => Promise<string | null>
Gets the mobile network code (MNC)
iOS only: Whether the carrier allows VoIP calls
Constants
Enum for cellular generation:
Cellular.Cellular.UNKNOWN
Cellular.Cellular.CELLULAR_2G
Cellular.Cellular.CELLULAR_3G
Cellular.Cellular.CELLULAR_4G
Cellular.Cellular.CELLULAR_5G
Examples
Display Carrier Info
import * as Cellular from 'expo-cellular';
import { useEffect, useState } from 'react';
import { Text, View } from 'react-native';
function CarrierInfo() {
const [info, setInfo] = useState<{
carrier: string | null;
country: string | null;
}>({ carrier: null, country: null });
useEffect(() => {
async function loadCarrierInfo() {
const carrier = await Cellular.getCarrierNameAsync();
const country = await Cellular.getIsoCountryCodeAsync();
setInfo({ carrier, country });
}
loadCarrierInfo();
}, []);
return (
<View>
<Text>Carrier: {info.carrier || 'Unknown'}</Text>
<Text>Country: {info.country?.toUpperCase() || 'Unknown'}</Text>
</View>
);
}
| Platform | Supported |
|---|
| iOS | ✅ |
| Android | ✅ |
| Web | ❌ |
Resources