flutter_sim_country_code icon indicating copy to clipboard operation
flutter_sim_country_code copied to clipboard

Country code returns null with some sims, esp from US

Open prashant2 opened this issue 4 years ago • 0 comments

In internal tests, in 2 out of 4 cases, country code returned was null. Both the failed cases had US sims. What could be wrong? Is country code access denied by some service providers?

1) Tester 1:US sim, currently tester in India. Country code returned null. Device: iPhone 12 Pro, iOS ver: 15.0.1 Debug message in Xcode:

'2021-12-03 19:56:38.646360+0530 Runner[28490:17949780] 
[Client] Updating selectors after delegate addition failed with: 
Error Domain=NSCocoaErrorDomain Code=4099 
"The connection to service with pid 94 named com.apple.commcenter.coretelephony.xpc 
was invalidated from this process." 
 UserInfo={NSDebugDescription=The connection to service with pid 94 
 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}'

Flutter exception: PlatformException(SIM_COUNTRY_CODE_ERROR, Error getting country, null, null)

2) Tester 2: US sim, currently in US. Country code returned null. Device: iPhone 12 Pro, iOS ver: 15.0.2

3) Tester 3: Indian sim, tester in India. Correct country code returned. Device: iPhone 8, iOS ver: 15.0

4) Tester 4: UK sim, tester in UK. Correct country code returned. Device: iPhone 8, iOS ver: 15.1

My flutter code:

static Future<String> getUserCountryCodeFromDevice() async {
  String sCountryCode = "";
  try {
    sCountryCode = await FlutterSimCountryCode.simCountryCode;
  } catch (e) { 
  }
  return sCountryCode;
}

prashant2 avatar Dec 04 '21 04:12 prashant2