Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can we retrieve the dual SIM numbers from the device in Flutter? #138

Open
hemanta321 opened this issue Jan 3, 2024 · 0 comments
Open

Comments

@hemanta321
Copy link

hemanta321 commented Jan 3, 2024

I want to retrieve the user's mobile number in Android. I am using the 'mobile_number' package to obtain dual SIM numbers from the device in Android. However, with this package, I am only able to retrieve the number for SIM 1.

I have used the following code, but I am not obtaining the number.


@override void initState() { 
MobileNumber.listenPhonePermission((isPermissionGranted) 
{ 
if (isPermissionGranted) 
{ initMobileNumberState(); } 
else {} 
}); 
initMobileNumberState();
super.initState();}

Future<void> initMobileNumberState() async { if (!await MobileNumber.hasPhonePermission) { await MobileNumber.requestPhonePermission; return; } 
try { 
// String  _mobileNumber = (await MobileNumber.mobileNumber)!; 
// toastMessage(text: "Mobile : $_mobileNumber"); 
List<SimCard>? simCards = await MobileNumber.getSimCards; 
for (SimCard simCard in simCards!) 
{ 
print("Carrier: ${simCard.carrierName}"); 
print("Country: ${simCard.countryIso}"); 
print("Number: ${simCard.number}"); 
} 
} 
on PlatformException catch (e) {
}

// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;

setState(() {});
}

I expect to retrieve both SIM numbers from the device.

@hemanta321 hemanta321 changed the title How we get dual sim number from the device in flutter How can we retrieve the dual SIM numbers from the device in Flutter? Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant