iosobjective-ciphonexcodemfmessagecomposeviewcontroller

iOS : Check whether the phone is dual SIM?


In Android we can detect whether the phone is Single SIM or Dual SIM. And as we know iPhone XS, iPhone XS Max, iPhone XR, and later feature Dual SIM with a nano-SIM and an eSIM except china mainland where there is no eSIM.

A) I can programatically invoke MFMessageComposeViewController from a button click to send the SMS to a particular number. Here is the following code: This code can tell us whether the SIM is inserted or not. But will it work for eSIM too?

-(void)openMessageViewWithName:(NSString*)contactName withPhone:(NSString *)phone{

CTTelephonyNetworkInfo *networkInfo=[[CTTelephonyNetworkInfo alloc]init];

CTCarrier *carrier=networkInfo.subscriberCellularProvider;

NSString *Countrycode = carrier.isoCountryCode;

if ([Countrycode length]>0)     //Check If Sim Inserted
{

    [self sendSMS:msg recipientList:[NSMutableArray arrayWithObject:phone]];
}
else
{

    [AlertHelper showAlert:@"Message" withMessage:@"No sim card inserted"];
}

//Method for sending message:

   - (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSMutableArray *)recipients{  
 MFMessageComposeViewController *controller1 = [[MFMessageComposeViewController alloc] init] ;
 controller1 = [[MFMessageComposeViewController alloc] init] ;
 if([MFMessageComposeViewController canSendText])
{
    controller1.body = bodyOfMessage;
    controller1.recipients = recipients;
    controller1.messageComposeDelegate = self;
    [self presentViewController:controller1 animated:YES completion:Nil];
 }
}

B) Is it possible to determine whether my iPhone is Dual SIM or Single SIM programatically? If yes it is DUAL SIM then can we choose the SIM from my application to send the SMS ?

Please help me with these and help me with a workaround .


Solution

  • As @PaulW11 mentioned in comment "No, you cannot detect sim details nor select the sim that is used to send messages. This is controlled by the user " Read Carefully for understanding

    A) First of all no SIM related datas or phone number you are going to get in iOS, the only details you get is regarding the network like carriername,mobilecountrycode,isocountrycode,mobilenetworkcode. So if you replace a Verizon SIM with Verizon you will see the carrier name as Verizon only , nothing else you are going to get

    SOLUTION Invoke MFMessageController from a button click as you are doing.This opens the iOS default SMS/Messages app. Then allow the user to choose the SIM in case of Dual SIM from the Messages App itself.

    B) It is not possible to select the particular SIM/Phone Number inside your application. Because there is no provision in iOS to do that as in Android. Instead you must invoke the default messages app in iOS where you can choose your desired SIM (in case of DUAL sim) for sending SMS or else in case of single SIM it directly sends the message from that number