Device features

You are currently viewing the AWS SDK for Mobile documentation which is a collection of low-level libraries. Use the Amplify libraries for all new app development. Learn more

You can view the Mobile SDK API reference here.

You can use the device related features of Amazon Cognito User Pools by enabling the Devices features. Navigate to the Cognito User Pools console, click on Devices in Left Navigation Menu and chose one of User Opt In or Always.

If you chose Always every device used by your application users is remembered.

You can read more about the device features in the following blog.

Terminology

  • Tracked

When devices are tracked, a set of device credentials consisting of a key and secret key pair is assigned to every device. You can view all tracked devices for a specific user from the Amazon Cognito console device browser, which you can view by choosing a user from the Users panel. In addition, you can see some metadata (whether it is remembered, time it began being tracked, last authenticated time, etc.) associated with the device and its usage.

  • Remembered

Remembered devices are also tracked. During user authentication, the 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 to the application. You can also see remembered devices from the Amazon Cognito console.

  • Not Remembered

A not-remembered device is the flipside of being remembered, though the device is still tracked. The device is treated as if it was never used during the user authentication flow. This means that the device credentials are not used to authenticate the device. The new APIs in the AWS Mobile SDK do not expose these devices, but you can see them in the Amazon Cognito console.

Remember Device

This option will mark the tracked device as remembered

1AWSMobileClient.default().deviceOperations.updateStatus(remembered: true) { (result, error) in
2 // ...
3}

Update Device

This option will mark the tracked device as not remembered.

1AWSMobileClient.default().deviceOperations.updateStatus(remembered: false) { (result, error) in
2 // ...
3}

Forget Device

This option will stop tracking the device altogether.

1AWSMobileClient.default().deviceOperations.forget({ (error) in
2 // ...
3})

Note: Once you call forget, you can update the status of the device in the same auth session. The end user will have to sign in again to remember the device.

Get Device Details

1AWSMobileClient.default().deviceOperations.get { (device, error) in
2 guard error == nil else {
3 print(error!.localizedDescription)
4 return
5 }
6
7 print(device!.createDate!)
8 print(device!.deviceKey!)
9
10}

List Devices

1AWSMobileClient.default().deviceOperations.list(limit: 60) { (result, error) in
2 guard error == nil else {
3 print(error!.localizedDescription)
4 return
5 }
6 // Number of devices that are remembered
7 print(result!.devices!.count)
8
9}