Native Flow Errors
When a Native Flow can't finish, the mobile SDKs report the failure to your app through a callback. That happens when the network drops or the flow can't load. Errors inside the flow, such as a wrong OTP code or a canceled passkey prompt, stay in the flow UI and never reach your app.
On iOS, the failure arrives in flowViewControllerDidFail on your DescopeFlowViewControllerDelegate, and a user cancellation arrives separately in flowViewControllerDidCancel. On Android, both arrive in onError on your DescopeFlowView.Listener. You can match on the error type to decide what to show, and read message or cause when you need more detail for logging.
The example below offers a retry for network failures and closes the flow screen for the others. showRetry and showError stand in for your own app's UI. When the user cancels the flow, the SDK calls flowViewControllerDidCancel instead of this callback.
func flowViewControllerDidFail(_ controller: DescopeFlowViewController, error: DescopeError) {
if error == .networkError {
// Offline, timed out, or the server was unreachable
showRetry(message: error.message ?? error.localizedDescription)
} else if error == .flowFailed {
// The flow couldn't complete
showError(error)
navigationController?.popViewController(animated: true)
} else {
// Any other error
showError(error)
}
}| Error | When it happens |
|---|---|
.networkError | The device is offline, the request timed out, or the server was unreachable. For a 5xx response, error.message includes the status code, for example "The server was unreachable with status code 503". |
.flowFailed | The flow failed to run or finished without a valid authentication response. |
Avoid restarting the flow automatically from this callback. A message with a retry button, or a return to your sign-in screen, gives the user control and avoids a loop when the network stays down.
To control how errors behave inside the flow itself, you can use the error handling options in Customizing Flow Errors.