Giter Club home page Giter Club logo

react-native-device-country's Introduction

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

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 devive without SIM card.

Contributing

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

License

MIT

react-native-device-country's People

Contributors

mshekspirtt avatar juancarlosqr avatar markneh avatar salimhb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.