Flutter dual sim -Send SMS

Issue

I have a dual sim android phone. I want to send SMS by selecting sim slots through flutter dart programatically. When i tried , by default , it is going from first sim slot. Is there any solution in flutter , as like in subscriptionManager() in android.

Solution

I tried with below code in android native and then bridge to Flutter with platform channels.And it worked for me.

      SubscriptionManager localSubscriptionManager = (SubscriptionManager)getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
      
        if (localSubscriptionManager.getActiveSubscriptionInfoCount() > 1) {
            List localList = localSubscriptionManager.getActiveSubscriptionInfoList();
            SubscriptionInfo simInfo = (SubscriptionInfo) localList.get(simSlot);
         
            SmsManager.getSmsManagerForSubscriptionId(simInfo.getSubscriptionId()).sendTextMessage(phone, null, smsContent, sentPI, deliveredPI);
        }else{
            List localList = localSubscriptionManager.getActiveSubscriptionInfoList();
            SubscriptionInfo simInfo = (SubscriptionInfo) localList.get(simSlot);
           
            sms = SmsManager.getDefault();
           
            sms.sendTextMessage(phone, null, smsContent, sentPI, deliveredPI);
        }

Answered By – user16647221-SIMJEC

Answer Checked By – Dawn Plyler (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.