GitHunt
DE

dev-family/react-native-device-country

Get device location by telephony (SIM card) or settings without using GPS tracker.

react-native-device-country

Get device location settings without using GPS tracker or by telephony (SIM card) (Android only)

npm version
npm
MIT


Platform - Android
Platform - iOS

๐Ÿ’œFOLLOW FOR RECENT NEWS๐Ÿ’œ

Installation

  • react-native-device-country V2 requires the new architecture/TurboModules to be enabled
  • for old architecture please use react-native-device-country V1.1.1
yarn add react-native-device-country

or

npm install react-native-device-country

Don't forget to run pod install after that!

Usage

import DeviceCountry from 'react-native-device-country';

// ...

DeviceCountry.getCountryCode()
  .then((result) => {
    console.log(result);
    // {"code": "BY", "type": "telephony"}
  })
  .catch((e) => {
    console.log(e);
  });

On Android you can use spicific method for getting country

TYPE_TELEPHONY for getting country code from SIM card

import DeviceCountry, {
  TYPE_TELEPHONY,
  TYPE_CONFIGURATION,
  TYPE_ANY,
} from 'react-native-device-country';

DeviceCountry.getCountryCode(TYPE_TELEPHONY)
  .then((result) => {
    console.log(result);
    // {"code": "PT", "type": "telephony"}
  })
  .catch((e) => {
    console.log(e);
  });

or TYPE_CONFIGURATION for getting country code from phone language settings on Android

DeviceCountry.getCountryCode(TYPE_CONFIGURATION)
  .then((result) => {
    console.log(result);
    // {"code": "RU", "type": "config"}
  })
  .catch((e) => {
    console.log(e);
  });

TYPE_ANY will be used by default. It tries to use TYPE_TELEPHONY (on Android) and fallbacks with TYPE_CONFIGURATION, if device without SIM card.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Languages

Kotlin30.3%TypeScript23.0%Swift22.3%Ruby9.1%JavaScript8.5%Objective-C++6.2%C0.6%

Contributors

MIT License
Created August 9, 2021
Updated January 7, 2026
dev-family/react-native-device-country | GitHunt