Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Update Sim.m #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/ios/Sim.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ - (void)getSimInfo:(CDVInvokedUrlCommand*)command
CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netinfo subscriberCellularProvider];

NSMutableDictionary *carriers = [[NSMutableDictionary alloc] init];
if (@available(iOS 12.0, *)) {
NSDictionary *carrierObjects = [netinfo serviceSubscriberCellularProviders];
for (NSString* key in carrierObjects) {
carriers[key] = [NSDictionary dictionaryWithObjectsAndKeys:
@([carrierObjects[key] allowsVOIP]), @"allowsVOIP",
[carrierObjects[key] carrierName], @"carrierName",
[carrierObjects[key] isoCountryCode], @"countryCode",
[carrierObjects[key] mobileCountryCode], @"mcc",
[carrierObjects[key] mobileNetworkCode], @"mnc",
nil];
}
}

BOOL allowsVOIPResult = [carrier allowsVOIP];
NSString *carrierNameResult = [carrier carrierName];
NSString *carrierCountryResult = [carrier isoCountryCode];
Expand All @@ -44,7 +58,8 @@ - (void)getSimInfo:(CDVInvokedUrlCommand*)command
carrierNameResult, @"carrierName",
carrierCountryResult, @"countryCode",
carrierCodeResult, @"mcc",
carrierNetworkResult, @"mnc",
carrierNetworkResult, @"mnc",
carriers, @"cards",
nil];

CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:simData];
Expand Down