SDK reference, Android SDK / Android Individual Modules

Phone

The Phone module collects a user's phone number and can confirm phone ownership by sending a one-time password (OTP) via SMS. With Silent Network Authentication (SNA), the module can confirm the number through the mobile network, without an SMS.

For an overview of this module and how it works, see Phone Number Input.

How you use this module depends on your integration pattern. In Patterns 1 and 2, you add the module to a FlowConfig in code as shown on this page. In Pattern 3, you define your modules and configuration in Dashboard as a Flow or Workflow and reference it by ID with startFlow() or startWorkflow() as shown on Run Flows Configured in Dashboard.

Add Phone

  1. Add the module with addPhone() (default config) or addPhone(phone) (custom config):
flowConfigBuilder.addPhone()
// or with a configured instance:
flowConfigBuilder.addPhone(phone)
flowConfigBuilder.addPhone();
// or with a configured instance:
flowConfigBuilder.addPhone(phone);
  1. If your flow also uses the AES (Advanced Electronic Signature) module, add it after Phone. AES requires Phone, along with ID Scan and Selfie Scan, to run first.

Phone ships both a v1 (legacy View) and a v2 (Jetpack Compose) capture screen; the active one depends on your Incode configuration. Contact your Incode representative to enable v2.

Example

The example below builds a Phone module with OTP verification enabled, adds it to the flow, and listens for the result through onAddPhoneCompleted().

val phone = Phone.Builder()
    .setOtpVerificationEnabled(true)
    .build()

val flowConfig = FlowConfig.Builder()
    .addPhone(phone)
    .build()

val onboardingListener = object : OnboardingListener() {
    override fun onAddPhoneCompleted(phoneNumberResult: PhoneNumberResult) {
        // Phone number captured. Process the result.
    }
}

IncodeWelcome.getInstance()
    .startOnboarding(activityContext, sessionConfig, flowConfig, onboardingListener)
Phone phone = new Phone.Builder()
    .setOtpVerificationEnabled(true)
    .build();

FlowConfig flowConfig = new FlowConfig.Builder()
    .addPhone(phone)
    .build();

IncodeWelcome.OnboardingListener onboardingListener = new IncodeWelcome.OnboardingListener() {
    @Override
    public void onAddPhoneCompleted(@NonNull PhoneNumberResult phoneNumberResult) {
        // Phone number captured. Process the result.
    }
};

IncodeWelcome.getInstance()
    .startOnboarding(activityContext, sessionConfig, flowConfig, onboardingListener);

Configuration Options

Configure the module with Phone.Builder. The table below lists the available options.

Setting Description
setOtpVerificationEnabled(Boolean) If true, shows OTP verification after the user enters a phone number. Defaults to false. In Capture-Only mode, OTP is not activated even when enabled. When SNA is enabled and cannot verify the number, this setting decides the fallback. See Enable Silent Network Authentication.
setDefaultRegionPrefix(Integer) Sets a dialing prefix that overrides the prefix derived from the carrier or the device's current region. Valid values are up to 4 digits. Do not add a leading +.

For the complete option set, see Phone.Builder in API Reference.

Enable Silent Network Authentication

Silent Network Authentication (SNA) is a phone number verification method that authenticates users through their mobile network using real-time carrier signals. You can enable SNA for the Phone module. SNA is only available in Flows in Dashboard, not Workflows.

  1. Use Android SDK version 5.50.0 or higher. There is no separate -sna variant. No additional Maven repository or credentials are required.
  2. In a Flow in Dashboard, turn on Enable SNA verification in the Phone Number Input module.
  3. Start the onboarding flow using one of the following approaches:
    • startFlow: Specify configurationId inside SessionConfig.Builder().setConfigurationId(), and provide it as sessionConfig to startFlow.

      The Flow configuration drives SNA; no additional code is required.

    • startOnboarding or Sections (where your app builds the FlowConfig: Specify configurationId inside SessionConfig.Builder().setConfigurationId(), and provide it as sessionConfig to startOnboarding or setupOnboardingSession. Then pass the Phone module in your FlowConfig. For Sections, call startOnboardingSection with that Phone module.

      The Flow configuration enables SNA; there is no client-side API to turn it on.

Requirements and fallback behavior
  • When SNA is enabled, the module first checks the phone number that is stored in the session, without input from the user. The SDK shows "Checking your device…" while the check runs. When the check verifies the number, the SDK shows "Phone number verified!" and the user taps Continue. When the session has no phone number, the SDK shows the phone input and the typed number gets the same check.
  • SNA cannot verify the number when:
    • The number or carrier is not SNA-covered
    • There is no cellular data path: for example, airplane mode or a VPN-tunneled connection
    • The verification fails or times out. On a transient failure of the silent check, the SDK retries the check one time, then falls back.
  • When SNA cannot verify the number, setOtpVerificationEnabled decides the fallback:
    • OTP on: the SDK sends an SMS code and shows the OTP step. After a silent check, the phone input shows the session number first, and Continue sends the code.
    • OTP off: the SDK shows "Something went wrong" with a Continue button. The result is SUCCESS with phone set to null and error set to an IncodeGenericError. The onboarding continues with the next module.
  • The module ends when the user taps Continue on the result screen. onAddPhoneCompleted fires at that moment.
  • SNA requires Android API level 24 or higher. On older devices, the SDK skips SNA. The user types the number and gets an SMS code, also when OTP is off.
  • The network permissions SNA requires (CHANGE_NETWORK_STATE, ACCESS_WIFI_STATE, CHANGE_WIFI_STATE) are bundled with the SDK and added to your app’s merged manifest automatically; you do not need to declare them. They are normal, install-time permissions, so no user prompt is involved.
  • Optionally declaring the READ_PHONE_STATE runtime permission enables a 2G-network safety check. Devices on insecure 2G networks skip the SNA check and use the fallback above: the SMS code when OTP is on, the failure screen when OTP is off. The SDK never requests the permission itself. See the Add Optional Permissions section of Installation.
  • The third-party SDK that powers SNA is bundled inside onboard.aar; no additional Maven repository or credentials are required. If your app ships an open-source/third-party licenses screen, reproduce its license attribution. See Licenses.
  • Bundling adds roughly 150 KB to the onboard artifact. The bundled SDK stays dormant unless the flow configuration enables SNA. It is never loaded on devices below API level 24.
  • Onboarding driven by the Workflows API does not support SNA yet. Phone module configuration in Workflows does not expose an SNA setting. Use a flow configuration (configurationId) for SNA.

Result

Phone delivers a PhoneNumberResult to the onAddPhoneCompleted(PhoneNumberResult) callback on the OnboardingListener. Key fields include:

  • phone: The phone number captured from the user or verified by SNA; null when unavailable, for example when SNA could not verify the number and OTP is off.
  • Fields inherited from BaseResult:
    • resultCode: The ResultCode for this result.
    • error: The Throwable associated with the result, or null if there is none.
      • ERROR result: The Throwable that caused the failure.
      • SUCCESS result: null in most cases. It is non-null in two situations:
        • OTP is on, and the organization is limited and not permitted to send or check the code: The Throwable that describes the refusal. The phone number was collected but not verified.
        • SNA could not verify the number, and OTP is off: An IncodeGenericError. In this case, phone is null.
    • deviceStats: The DeviceStats snapshot of the device state when the result was produced.
    • motionStatus: Device motion assessment during capture. One of the following:
      • UNCLEAR: Motion could not be determined; the default.
      • PASS: Device motion was within acceptable limits.
      • FAIL: Excessive device motion was detected.

Errors surface through OnboardingListener.onError(Throwable). This module does not deliver a module-specific exception subtype.

For all fields, see PhoneNumberResult in the Android API Reference.

Was this page helpful?