Prerequisites
Before this page: create and initialize a Dynamic client (see Creating a Dynamic client, Initializing the Dynamic client), and have a signed-in user (see Email & SMS OTP sign-in).
What you’ll build
When your project requires device registration, a user signing in on an unrecognized device must approve it before continuing. You’ll build:
- Detection — notice when the current device needs approval.
- Completion — finish approval when the user returns from the approval link.
- Management — list registered devices and let the user revoke them.
Detecting the requirement
After sign-in, isDeviceRegistrationRequired tells you whether the current device still needs approval. You don’t send the approval email — the backend emails the link automatically when a user signs in on an unrecognized device. isDeviceRegistrationRequired just reflects that the current device is still pending, so use it to render a “check your email” message.
Completing approval on redirect
The approval link brings the user back to your app with a one-time token in the URL. Detect it, extract the token, and complete registration.
Managing registered devices
List the user’s devices and let them revoke any — or all — from a settings screen.
Revoking the current device — or all devices — signs the user out immediately. revokeAllRegisteredDevices always logs out; revokeRegisteredDevice logs out when the device being revoked is the current one. The SDK fires the logout event with reason device-revoked or all-devices-revoked; listen for it and send the user to your login screen so they aren’t left on a dead session.
Handling errors
See also