Code Monkey home page Code Monkey logo

flutter_device_region's Introduction

device_region

A Flutter plugin which uses platform-specific API to return a SIM country code. Supports iOS and Android.

Installation

In your Flutter project, in pubspec.yaml file add the dependency:

dependencies:
  device_region: ^1.0.1

Usage example

Import device_region.dart package.

import 'package:device_region/device_region.dart';

Get SIM country code

Call getSIMCountryCode method to receive SIM country code.

await DeviceRegion.getSIMCountryCode();
Android:

Using TelephonyManager class:

Returns simCountryIso if available. Otherwise, it should return networkCountryIso.

In case the value cannot be retrieved or an error occurs, null value will be returned

iOS:

Using CTTelephonyNetworkInfo class:

Returns isoCountryCode if available.

In case the value cannot be retrieved or an error occurs, null value will be returned

Important notes

  • While call getSIMCountryCode on iOS, it will return proper country code and can throw error log in debugger as below:
[Client] Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service with pid 91 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service with pid 91 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}

It's well known bug on iOS and it does not affect the operation of the application.

  • Method returns null in case if for some reason it was not possible to retrieve the information from the SIM slot. So it will return null i.e on iOS simulators and devices without SIM card inserted.

  • On iOS, it only works from 12.0 and above. For lower versions it will return null.

flutter_device_region's People

Forkers

kobeumut

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.