diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 8c14a50..833cf7c 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -2,6 +2,8 @@ + + sendVerificationSms({ + required BuildContext context, + required String destinationNumber, + required String message, + }) async { + try { + // Request permission to access SIM cards + await _simcards.requestPermission(); + + bool permissionGranted = await _simcards.hasPermission(); + if (!permissionGranted) { + print("❌ Permission denied."); + return; + } + + List simCardList = await _simcards.getSimCards(); + if (simCardList.isEmpty) { + print("❌ No SIM detected."); + return; + } + + // If only one SIM card is available, send SMS directly + if (simCardList.length == 1) { + await _sendSms(destinationNumber, message, simCardList.first); + return; + } + + // Show a dialog to let the user select a SIM card + int? selectedSimSlot = await showDialog( + context: context, + builder: (BuildContext dialogContext) { + int? tempSelection; + return AlertDialog( + title: const Text("Select SIM to send SMS"), + content: StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return DropdownButton( + hint: const Text("Choose SIM"), + value: tempSelection, + onChanged: (int? newValue) { + setState(() { + tempSelection = newValue; + }); + }, + items: List.generate(simCardList.length, (index) { + final sim = simCardList[index]; + return DropdownMenuItem( + value: index, + child: Text(sim.displayName ?? "SIM ${index + 1}"), + ); + }), + ); + }, + ), + actions: [ + TextButton( + onPressed: () { + Navigator.pop(dialogContext, tempSelection); + }, + child: const Text("OK"), + ), + ], + ); + }, + ); + + if (selectedSimSlot == null) { + print("⚠️ SIM not selected."); + return; + } + + // Send SMS using the selected SIM card + await _sendSms(destinationNumber, message, simCardList[selectedSimSlot]); + } catch (e) { + print("⚠️ Error sending SMS: $e"); + } + } + + Future _sendSms( + String destinationNumber, String message, SimCard selectedSim) async { + // SMS Logic Here + print("✅ SMS sent via ${selectedSim.displayName}"); + } +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 167c712..8b2ecee 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -813,6 +813,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + simcards: + dependency: "direct main" + description: + name: simcards + sha256: b621cc265ebbb3e11009ca9be67063efbc011396c4224aff8b08edaba30fa5ae + url: "https://pub.dev" + source: hosted + version: "0.0.1" sky_engine: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index 2bf26a7..f21de16 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -61,6 +61,7 @@ dependencies: device_info_plus: ^11.3.0 showcaseview: ^2.0.3 package_info_plus: ^4.2.0 + simcards: ^0.0.1 # jailbreak_root_detection: "^1.1.6"