SMS User Consent API for Android

Notice for App Developers

To use these methods, the SMS User Consent module must be installed in the native app:

Overview

Provides one-tap SMS verification without requiring specific message format. When an SMS arrives, the system shows a consent dialog. User taps once to approve, and the app receives the full message content.

Platform Support

  • Android: Full support via SMS User Consent API (requires Google Play Services)
  • iOS: Native autofill available (iOS 16+), no explicit module needed

Hierarchy

  • SmsUserConsent

Methods

Methods

  • Start SMS User Consent listener (Android only)

    When an SMS arrives, Android shows a bottom sheet with the message preview. User taps once to grant access, and the app receives the full SMS content.

    How It Works

    1. Call startSmsConsent() to begin listening
    2. When SMS arrives, system shows bottom sheet: "Verify your phone number?"
    3. User taps "Allow" (one tap)
    4. App receives full SMS message

    Parameters

    Returns Promise<SmsConsentOutput>

    Promise resolving to SmsConsentOutput with the full SMS message

    Example

    Basic usage

    const modules = await Eitri.modules()
    const smsUserConsentModule = modules.smsUserConsent

    if (!smsUserConsentModule) {
    console.error('SMS User Consent module is not available')
    return
    }

    try {
    const result = await smsUserConsentModule.startSmsConsent()
    console.log('SMS received:', result.message)
    // Parse the message to extract verification code if needed
    } catch (error) {
    console.error('User denied consent or error occurred:', error)
    // Show fallback: manual entry
    }

    Limitations

    • 5-minute timeout: The listening window expires after 5 minutes
    • One listener at a time: Only one active listener per app
    • Requires user interaction: User must tap once to approve (not fully automatic)
    • Android only: This API is Android-specific. iOS uses native autofill.

    Best Practices

    1. Always provide fallback: Allow users to manually enter verification codes if consent is denied
    2. Check module availability: Always verify module exists before use
    3. Handle all exceptions: Use try-catch to handle timeout, denial, and API unavailability
    4. Parse message content: Extract verification codes from the message on the client side
    5. Inform users: Let users know an SMS will arrive and they'll need to tap once

    Compatibility Control

    const modules = await Eitri.modules();
    if (!modules?.smsUserConsent) {
    // SMS User Consent module unavailable
    return;
    }

Generated using TypeDoc