Page updated Jan 16, 2024

Delete user account

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.

Amplify libraries should be used for all new cloud connected applications. If you are currently using the AWS Mobile SDK for iOS, you can access the documentation here.

Invoke the deleteUser API to delete a user from the Auth category. This action will also sign your user out.

If your application uses a Cognito User Pool, which is the default configuration for the Amazon Cognito plugin, this action will delete the user from the Cognito User Pool. It will have no effect if you are federating with a Cognito Identity Pool alone.

Depending on your application, data associated with your user may be stored in other resources such as Amazon DynamoDB or AWS S3. It is recommended that you carefully evaluate this data and implement code to remove or otherwise sanitize it, if necessary, prior to giving users the ability to delete their own user record.

Before invoking the “delete user” API, you can first delete associated user data from the GraphQL API. For example, if you are using Amplify CLI's GraphQL transformer to persist user data via owner based access control, you could follow these instructions to delete associated user data.

This allows you to address any guidelines that require your app to delete data associated with a user who deletes their account.

1func deleteUser() {
2 Amplify.Auth.deleteUser() { result in
3 switch result {
4 case .success:
5 print("Successfully deleted user")
6 case .failure(let error):
7 print("Delete user failed with error \(error)")
8 }
9 }
10}
1func deleteUser() -> AnyCancellable {
2 Amplify.Auth.deleteUser()
3 .resultPublisher
4 .sink {
5 if case let .failure(authError) = $0 {
6 print("Delete user failed with error \(authError)")
7 }
8 }
9 receiveValue: {
10 print("Successfully deleted user")
11 }
12}