device_region
이 플러그인은 플랫폼별 API를 사용하여 SIM 국가 코드를 반환합니다
플랫폼 고유의 API를 사용하여 SIM 국가 코드를 반환하는 Flutter 플러그인입니다. iOS 및 Android를 지원합니다.
{"sdk":"flutter"}{"sdk":"flutter"}^1.0.0아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
A Flutter plugin which uses platform-specific API to return a SIM country code. Supports iOS and Android.
In your Flutter project, in pubspec.yaml file add the dependency:
dependencies:
device_region: ^1.4.0
Import device_region.dart package.
import 'package:device_region/device_region.dart';
Call getSIMCountryCode method to receive SIM country code.
await DeviceRegion.getSIMCountryCode();
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
Due to deprecated properties in CTTelephonyNetworkInfo class, plugin uses Locale class and returns Locale.current.region.identifier.
Using CTTelephonyNetworkInfo class:
Returns isoCountryCode if available.
In case the value cannot be retrieved or an error occurs, null value will be returned
getSIMCountryCode on iOS (up to 16.0), it returns 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.