https://github.com/dev-family/react-native-device-country
Get device location by telephony (SIM card) or settings without using GPS tracker.
https://github.com/dev-family/react-native-device-country
device-location gps gps-location location phone-code phone-location phone-number react-native simcard
Last synced: 11 months ago
JSON representation
Get device location by telephony (SIM card) or settings without using GPS tracker.
- Host: GitHub
- URL: https://github.com/dev-family/react-native-device-country
- Owner: dev-family
- License: mit
- Created: 2021-08-09T13:55:55.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-06-04T07:59:22.000Z (about 1 year ago)
- Last Synced: 2025-07-04T18:45:15.855Z (11 months ago)
- Topics: device-location, gps, gps-location, location, phone-code, phone-location, phone-number, react-native, simcard
- Language: Java
- Homepage:
- Size: 1.36 MB
- Stars: 75
- Watchers: 5
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-device-country
Get device location settings without using GPS tracker or by telephony (SIM card) (Android only)
[](https://www.npmjs.org/package/react-native-device-country)
[](https://www.npmjs.org/package/react-native-device-country)
[](https://opensource.org/licenses/MIT)
[](https://www.android.com)
[](https://developer.apple.com/ios)
💜[FOLLOW FOR RECENT NEWS](https://twitter.com/dev___family)💜
## Installation
```sh
yarn add react-native-device-country
```
or
```sh
npm install react-native-device-country
```
_Don't forget to run `pod install` after that!_
## Usage
```js
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
```js
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
```js
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](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
## License
MIT
