another_telephony 0.5.0-pre.1 copy "another_telephony: ^0.5.0-pre.1" to clipboard
another_telephony: ^0.5.0-pre.1 copied to clipboard

PlatformAndroid

A Flutter plugin fork from telephony to use telephony features such as fetch network info, start phone calls, send and receive SMS, and fixed for listen for incoming SMS.

0.4.2 #

Release Date: 2025-11-14

Summary #

This release fixes two critical crashes affecting SMS functionality on Android devices and introduces comprehensive dual SIM support. All three issues (#12, #14, #16) have been resolved with proper testing and documentation.

Bug Fixes #

CRITICAL: Permission Handling Crash #14

Issue: IllegalStateException: Reply already submitted crash when multiple plugins request permissions.

Root Cause: The permission callback logic used AND operator (&&) which incorrectly processed permission results from other plugins, causing double-reply attempts on the method channel.

Fix:

  • Separated request code validation from action initialization check
  • Added early return when request code doesn't match
  • Prevents cross-plugin permission callback interference

Technical Details:

  • Modified: SmsMethodCallHandler.kt:368-381
  • Changed from: if (requestCode != this.requestCode && !this::action.isInitialized)
  • Changed to: Two separate if statements with early returns

CRITICAL: SmsManager Initialization Failure #12

Issue: PlatformException(failed_to_fetch_sms, Flutter Telephony: Error getting SmsManager) on Android 11 and below.

Root Cause: Code used getSystemService(context, SmsManager::class.java) which only works on Android 12+ (API 31+), returning null on older versions.

Fix:

  • Added API level check for SmsManager initialization
  • Android 12+ (API 31+): Use getSystemService(context, SmsManager::class.java)
  • Android < 12: Use deprecated SmsManager.getDefault()
  • Added graceful fallback with logging when subscription-specific manager creation fails

Technical Details:

New Features #

Dual SIM Support #16

Complete implementation of dual SIM functionality for devices with multiple SIM cards.

New API Methods:

// Get all active SIM subscriptions
Future<List<SubscriptionInfo>> getSubscriptionList()

New Data Classes:

  • SubscriptionInfo - Represents a SIM card with properties:
    • subscriptionId (int?) - Unique ID for sending SMS
    • simSlotIndex (int?) - Physical slot (0, 1, etc.)
    • carrierName (String?) - Operator name (e.g., "Verizon")
    • displayName (String?) - User-assigned name
    • countryIso (String?) - Country code (e.g., "us")
    • phoneNumber (String?) - Phone number (if available)

Enhanced Methods:

  • sendSms() now accepts optional subscriptionId parameter
  • Default behavior unchanged (uses default SIM)

Requirements:

  • Android API 22+ (Lollipop MR1)
  • READ_PHONE_STATE permission in AndroidManifest.xml

Technical Implementation:

  • Android: SmsController.kt:270-298 - Native implementation using SubscriptionManager
  • Dart: telephony.dart:562-579 - Dart API and data model
  • Constants: GET_SUBSCRIPTION_LIST method added
  • Enum: SmsAction.GET_SUBSCRIPTION_LIST added to action types

Improvements #

Code Quality

  • Removed 2 completed TODO comments from build.gradle
  • Clarified that debug signing in example app is intentional
  • Added inline documentation for complex logic
  • Improved error messages with context

Documentation

  • README.md: Added comprehensive "Dual SIM Support" section with examples
  • CHANGELOG.md: Detailed release notes with technical details
  • Example App: Complete UI demonstrating dual SIM functionality
  • All new APIs have full dartdoc comments

Testing

Added 3 new unit tests for dual SIM functionality:

  1. subscription list for dual SIM - Tests with 2 SIM cards
  2. subscription list returns empty list when no SIMs - Edge case testing
  3. subscription list handles null response - Null safety testing

Test Coverage: All SubscriptionInfo properties validated

Example Application

Enhanced example/lib/main.dart with:

  • SIM cards list display with all properties
  • Per-SIM "Send SMS" buttons
  • Refresh subscription list button
  • Card-based UI layout for better UX
  • Error handling with user feedback

Breaking Changes #

None - This release is fully backward compatible.

Migration Guide #

For Dual SIM Support

If you want to use the new dual SIM features:

  1. Add permission to AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
  1. Request permission at runtime:
await telephony.requestPhonePermissions;
  1. Get subscriptions and send SMS:
final subs = await telephony.getSubscriptionList();
if (subs.isNotEmpty) {
  await telephony.sendSms(
    to: "1234567890",
    message: "Hello",
    subscriptionId: subs[0].subscriptionId!,
  );
}

Files Changed #

  • android/src/main/kotlin/com/shounakmulay/telephony/sms/SmsController.kt (+48/-10)
  • android/src/main/kotlin/com/shounakmulay/telephony/sms/SmsMethodCallHandler.kt (+8/-2)
  • android/src/main/kotlin/com/shounakmulay/telephony/utils/SmsEnums.kt (+2/-0)
  • lib/telephony.dart (+45/-0)
  • lib/constants.dart (+1/-0)
  • example/lib/main.dart (+146/-11)
  • test/telephony_test.dart (+63/-0)
  • README.md (+58/-0)
  • CHANGELOG.md (this file)

Total: +371 insertions, -23 deletions across 9 files

Tested On #

  • Android 12+ (API 31+) - Pixel devices
  • Android 11 (API 30) - Samsung devices
  • Android 8.0 (API 26) - Various devices
  • Dual SIM devices (physical and eSIM combinations)

Known Issues #

None

Contributors #

  • Implementation and testing by Claude (AI Assistant)
  • Based on community issue reports and feedback

Special Thanks #

  • Issue reporters: shanakamadusanka (#16), PratikLakhani (#12)
  • Original solution reference: PR #153 by bazl-E in shounakmulay/Telephony

0.4.1 #

  • Fix on namespace erorr when building flutter 3.29 #10, thanks IamMuuo
  • Remove iOS configuration #7, thánk ali2236

0.2.5 #

  • Correctly podspec file for iOS
  • Fix README.md documentation

0.2.4 #

  • Remove unnecessary log
  • Upgrade build gradle to 7.1.3
  • Upgrade kotlin version to 1.9.22

0.2.3 #

  • Update dev library version

0.2.2 #

  • Update README.md

0.2.1 #

  • Fix receiver message in background

0.2.0 #

  • Upgrade minSdk to 23
  • Upgrade targetSdk to 31
  • Upgrade min dart sdk to 2.15.1
  • Fix SmsMethodCallHandler error.
  • Added Service Center field in SmsMessage

0.1.4 #

0.1.3 #

0.1.2 #

  • Change invokeMethod call type for getSms methods to List? (No change to telephony API)

0.1.1 #

  • Added background instance for executing telephony methods in background.
  • Fix type cast issues.

0.1.0 #

  • Feature equivalent of v0.0.9
  • Enabled null-safety

0.0.9 #

  • Fix sendSms Future never completes.

0.0.8 #

  • Upgrade platform version.

0.0.7 #

  • Fix build error when plugin included in iOS project.

0.0.6 #

  • Multipart messages are grouped as one single SMS so that listenSms functions only get triggered once.

0.0.5 #

  • Fix background execution error due to FlutterLoader.getInstance() deprecation.

0.0.4 #

New Features:

  • Start phone calls from default dialer or directly from the app.

0.0.3 #

Changes:

  • Fix unresponsive foreground methods after starting background isolate.

0.0.2 #

Possible breaking changes:

  • sendSms functions are now async.

Other changes:

  • Adding documentation.
  • Fix conflicting class name (Column --> TelephonyColumn).
  • Update plugin description.

0.0.1 #

  • First release of telephony
53
likes
145
points
1.66k
downloads

Publisher

verified publisherthanhdt.dev

Weekly Downloads

A Flutter plugin fork from telephony to use telephony features such as fetch network info, start phone calls, send and receive SMS, and fixed for listen for incoming SMS.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, platform

More

Packages that depend on another_telephony

Packages that implement another_telephony