Flutter 双卡 - 发送短信

Flutter dual sim -Send SMS

我有双卡 android phone。我想通过 flutter dart 以编程方式选择 sim 插槽来发送短信。当我尝试时,默认情况下,它是从第一个 sim 插槽开始的。在 flutter 中有没有解决方案,比如 android.

中的 subscriptionManager()

我尝试在 android 原生中使用以下代码,然后使用平台 channels.And 桥接到 Flutter,它对我有用。

      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);
        }