Description:
A JavaScript library for React Native that allows you to get device location by telephony (SIM card) or settings without using GPS tracker.
How to use it:
1. Install and import the react-native-device-country.
# Yarn $ yarn add react-native-device-country # NPM $ npm i react-native-device-country --save
import DeviceCountry, {
TYPE_ANY,
TYPE_TELEPHONY,
TYPE_CONFIGURATION,
} from 'react-native-device-country';2. Get device location (country code).
DeviceCountry.getCountryCode()
.then((result) => {
console.log(result);
// {"code": "US", "type": "telephony"}
})
.catch((e) => {
console.log(e);
});3. Get device location from SIM card.
DeviceCountry.getCountryCode(TYPE_TELEPHONY)
.then((result) => {
console.log(result);
// {"code": "US", "type": "telephony"}
})
.catch((e) => {
console.log(e);
});4. Get device location from location settings.
DeviceCountry.getCountryCode(TYPE_CONFIGURATION)
.then((result) => {
console.log(result);
// {"code": "US", "type": "config"}
})
.catch((e) => {
console.log(e);
});