Page updated Nov 9, 2023

Remember a device

Amplify iOS v1 is now in Maintenance Mode until May 31st, 2024. This means that we will continue to include updates to ensure compatibility with backend services and security. No new features will be introduced in v1.

Please use the latest version (v2) of Amplify Library for Swift to get started.

If you are currently using v1, follow these instructions to upgrade to v2.

Remembering a device is useful in conjunction with Multi-Factor Authentication (MFA). If MFA is enabled for an Amazon Cognito user pool, end users have to type in a security code received via e-mail or SMS each time they want to sign in. This increases security but comes at the expense of the user's experience.

Remembering a device allows the second factor requirement to be automatically met when the user signs in on that device, thereby reducing friction in the user experience.

Configure Auth Category

Device remembering functionality does not work if you use one of the web UI sign in methods.

To enable remembered device functionality, open the Cognito User Pool console. To do this, go to your project directory and issue the command:

amplify auth console
1amplify auth console

Select the following option to open the Cognito User Pool console:

? Which Console User Pool
1? Which Console
2 User Pool

When the console opens, click on Devices from the left navigation menu, which will render the following page allowing you to configure your preference for remembering a user's device.


Choose either Always or User Opt in depending on whether you want to remember a user's device by default or give the user the ability to choose.

If MFA is enabled for the Cognito user pool, you will have the option to suppress the second factor during multi-factor authentication. Choose Yes if you want a remembered device to be used as a second factor mechanism or No otherwise.


When you have made your selection(s), click "Save changes". You are now ready to start updating your code to manage your remembered devices.


Remember Device

You can mark your device as remembered:

func rememberDevice() { Amplify.Auth.rememberDevice() { result in switch result { case .success: print("Remember device succeeded") case .failure(let error): print("Remember device failed with error \(error)") } } }
1func rememberDevice() {
2 Amplify.Auth.rememberDevice() { result in
3 switch result {
4 case .success:
5 print("Remember device succeeded")
6 case .failure(let error):
7 print("Remember device failed with error \(error)")
8 }
9 }

Forget Device

You can forget your device by using the following API. Note that forgotten devices are still tracked. See below for the difference between remembered, forgotten and tracked.

func forgetDevice() { Amplify.Auth.forgetDevice() { result in switch result { case .success: print("Forget device succeeded") case .failure(let error): print("Forget device failed with error \(error)") } } }
1func forgetDevice() {
2 Amplify.Auth.forgetDevice() { result in
3 switch result {
4 case .success:
5 print("Forget device succeeded")
6 case .failure(let error):
7 print("Forget device failed with error \(error)")
8 }
9 }

Fetch Devices

You can fetch a list of remembered devices by using the following:

func fetchDevices() { Amplify.Auth.fetchDevices() { result in switch result { case .success(let fetchDeviceResult): for device in fetchDeviceResult { print( } case .failure(let error): print("Fetch devices failed with error \(error)") } } }
1func fetchDevices() {
2 Amplify.Auth.fetchDevices() { result in
3 switch result {
4 case .success(let fetchDeviceResult):
5 for device in fetchDeviceResult {
6 print(
7 }
8 case .failure(let error):
9 print("Fetch devices failed with error \(error)")
10 }
11 }


  • Tracked
    • Every time the user signs in with a new device, the client is given the device key at the end of a successful authentication event. We use this device key to generate a salt and password verifier which is used to call the ConfirmDevice API. At this point, the device is considered to be tracked. Once the device is in a tracked state, you can use the Amazon Cognito console to see the time it started to be tracked, last authentication time, and other information about that device.
  • Remembered
    • Remembered devices are also tracked. During user authentication, the device key and secret pair assigned to a remembered device is used to authenticate the device to verify that it is the same device that the user previously used to sign in.
  • Not Remembered
    • A not-remembered device is a tracked device where Cognito has been configured to require users to "Opt-in" to remember a device, but the user has not opt-ed in to having the device remembered. This use case is used for users signing into their application from a device that they don't own.
  • Forgotten
    • In the event that you no longer want to remember or track a device, you can use the Amplify.Auth.forgetDevice() API to remove this device from being both remembered and tracked.

Known Limitations

When using the federated OAuth flow with Cognito User Pools, the device tracking and remembering features are currently not available within the library.