The Phone module collects a user's phone number and can confirm phone ownership by sending a one-time password (OTP) via 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. When the app defines the steps in code, you add the module to an IncdOnboardingFlowConfiguration as shown below; when the flow is defined in Dashboard, you reference it by ID. See Integration Approaches.
Availability: All variants; the -sna build adds Silent Network Authentication features.
UI: v1 and v2.
Add Phone
Add the module with addPhone(). Both parameters are optional; call addPhone() with no arguments to use the default configuration.
flowConfig.addPhone(
otpVerification: true,
defaultRegionPrefix: 1 // optional dial code, 1…9999
)
Example
The example below builds a flow with the Phone module, enables OTP verification, starts onboarding, and listens for the result through onAddPhoneNumberCompleted(_:) on IncdOnboardingDelegate.
final class VerificationCoordinator: IncdOnboardingDelegate {
func startVerification(sessionToken: String) {
let flow = IncdOnboardingFlowConfiguration()
flow.addPhone(otpVerification: true)
let session = IncdOnboardingSessionConfiguration(token: sessionToken)
IncdOnboardingManager.shared.startOnboarding(
sessionConfig: session,
flowConfig: flow,
delegate: self
)
}
// MARK: - IncdOnboardingDelegate
func onAddPhoneNumberCompleted(_ result: PhoneNumberResult) {
// Phone number captured. Process the result.
let phone = result.phone
}
}
Configuration Options
Configure the module with addPhone().
| Option | Type | Description |
|---|---|---|
otpVerification |
Bool? |
If true, shows OTP verification after the user enters a phone number. When nil, shows the value configured on the Workflow (via OTPConfiguration) or the manager flag. |
defaultRegionPrefix |
Int? |
Sets a dialing prefix that overrides the prefix derived from the carrier or the device's current region. Valid values are integers greater than 0, up to four digits; invalid values are ignored and the default region prefix is used. Do not add a leading +. |
You can also enable SMS OTP globally on the manager with enableSMSOTPVerification: a UserDefaults-backed flag, false by default. OTP expiration and prefill are determined by the Workflow's OTPConfiguration.
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.
- Use an iOS SDK variant that includes the
-snasuffix: for example,5.43.0-s-sna. - In a Flow in Dashboard, turn on Enable SNA verification in the Phone Number Input module.
- Start the onboarding flow using one of the following approaches:
startFloworstartOnboarding: SpecifyconfigurationIdinsideIncdOnboardingSessionConfiguration, and provide it assessionConfigtostartFloworstartOnboardingmethod.- Sections: Specify
configurationIdinsideIncdOnboardingSessionConfiguration, and provide it assessionConfigtosetupOnboardingSession. Then callstartOnboardingSectionwith the Phone module provided toIncdOnboardingSessionConfiguration.
Result
Phone delivers a PhoneNumberResult to the onAddPhoneNumberCompleted(_:) callback on your IncdOnboardingDelegate:
func onAddPhoneNumberCompleted(_ result: PhoneNumberResult)
PhoneNumberResult fields:
phone: String?: The phone number captured from the user;nilwhen unavailable.error: IncdError?: The error that occurred while capturing the phone number, if any; otherwise,nil.