@@ -29,7 +29,7 @@ public String getName() {
2929
3030 @ ReactMethod
3131 public void carrierName (Promise promise ) {
32- String carrierName = mTelephonyManager .getNetworkOperatorName ();
32+ String carrierName = mTelephonyManager .getSimOperatorName ();
3333 if (carrierName != null ) {
3434 promise .resolve (carrierName );
3535 } else {
@@ -39,40 +39,42 @@ public void carrierName(Promise promise) {
3939
4040 @ ReactMethod
4141 public void isoCountryCode (Promise promise ) {
42- String iso = mTelephonyManager .getNetworkCountryIso ();
42+ String iso = mTelephonyManager .getSimCountryIso ();
4343 if (iso != null ) {
4444 promise .resolve (iso );
4545 } else {
4646 promise .reject (E_NO_ISO_COUNTRY_CODE , "No iso country code" );
4747 }
4848 }
4949
50+ // returns MCC (3 digits)
5051 @ ReactMethod
5152 public void mobileCountryCode (Promise promise ) {
52- String mcc = mTelephonyManager .getNetworkOperator ();
53- if (mcc != null ) {
54- promise .resolve (mcc );
53+ String plmn = mTelephonyManager .getSimOperator ();
54+ if (plmn != null ) {
55+ promise .resolve (plmn . substring ( 0 , 3 ) );
5556 } else {
5657 promise .reject (E_NO_MOBILE_COUNTRY_CODE , "No mobile country code" );
5758 }
5859 }
5960
61+ // returns MNC (2 or 3 digits)
6062 @ ReactMethod
6163 public void mobileNetworkCode (Promise promise ) {
62- String mnc = mTelephonyManager .getNetworkOperator ();
63- if (mnc != null ) {
64- promise .resolve (mnc );
64+ String plmn = mTelephonyManager .getSimOperator ();
65+ if (plmn != null ) {
66+ promise .resolve (plmn . substring ( 3 ) );
6567 } else {
6668 promise .reject (E_NO_MOBILE_NETWORK , "No mobile network code" );
6769 }
6870 }
6971
70- // return MCC + MNC, e.g. 46697
72+ // return MCC + MNC (5 or 6 digits) , e.g. 20601
7173 @ ReactMethod
7274 public void mobileNetworkOperator (Promise promise ) {
73- String operator = mTelephonyManager .getNetworkOperator ();
74- if (operator != null ) {
75- promise .resolve (operator );
75+ String plmn = mTelephonyManager .getSimOperator ();
76+ if (plmn != null ) {
77+ promise .resolve (plmn );
7678 } else {
7779 promise .reject (E_NO_NETWORK_OPERATOR , "No mobile network operator" );
7880 }
0 commit comments