Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Apr 29, 2024

Delete user account

Amplify iOS v1 is deprecated as of June 1st, 2024. No new features or bug fixes will be added. Dependencies may become outdated and potentially introduce compatibility issues.

Please use the latest version (v2) of Amplify Library for Swift to get started. Refer to the upgrade guide for instructions on upgrading your application to the latest version.

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.

func deleteUser() {
Amplify.Auth.deleteUser() { result in
switch result {
case .success:
print("Successfully deleted user")
case .failure(let error):
print("Delete user failed with error \(error)")
}
}
}
func deleteUser() -> AnyCancellable {
Amplify.Auth.deleteUser()
.resultPublisher
.sink {
if case let .failure(authError) = $0 {
print("Delete user failed with error \(authError)")
}
}
receiveValue: {
print("Successfully deleted user")
}
}