In-App Account Deletion in Flutter with Firebase (App Store & Google Play Compliant)

Implement in-app account deletion in a Flutter app with Firebase Auth — re-authentication, deleting user data, Sign in with Apple token revocation and the Google Play web deletion link.

Darko Bačić, authorDarko Bačić 4 min read
On this page
  1. What "account deletion" must include
  2. 1. The confirmation UI
  3. 2. Delete the Firebase Auth user
  4. 3. Re-authenticate
  5. 4. Delete the user's data on the server
  6. 5. Sign in with Apple: revoke tokens
  7. 6. Google Play web deletion link
  8. 7. After deletion
  9. Testing checklist

Both Apple and Google require that if users can create an account in your app, they can also delete it — and on iOS, deletion must be initiated from inside the app. It's one of the most common reasons for App Store rejections, and it's easy to build if you plan for it.

This tutorial covers a robust implementation with Firebase Authentication.

##What "account deletion" must include

  • An easy-to-find option in the app, usually Settings → Account → Delete account
  • Deletion of the account and associated personal data, not just deactivation (you may keep data you're legally required to retain — tell the user)
  • A clear confirmation step, so users don't delete by accident
  • On Google Play: a web link where users can request deletion without reinstalling the app, declared in Play Console
  • For apps using Sign in with Apple: revoking the user's Apple tokens

##1. The confirmation UI

Keep it honest and simple: explain what will be deleted, mention active subscriptions (deleting an account does not cancel an App Store or Google Play subscription — link users to manage it), and require an explicit confirmation.

dart
Future<bool> confirmDeletion(BuildContext context) async {
  return await showDialog<bool>(
        context: context,
        builder: (ctx) => AlertDialog(
          title: const Text('Delete your account?'),
          content: const Text(
            'This permanently deletes your account and data. '
            'Active subscriptions must be cancelled separately in your store settings.',
          ),
          actions: [
            TextButton(
              onPressed: () => Navigator.pop(ctx, false),
              child: const Text('Cancel'),
            ),
            TextButton(
              onPressed: () => Navigator.pop(ctx, true),
              child: const Text('Delete'),
            ),
          ],
        ),
      ) ??
      false;
}

##2. Delete the Firebase Auth user

Firebase only allows deleting a user who signed in recently. Otherwise delete() throws a requires-recent-login error and you need to re-authenticate first.

dart
import 'package:firebase_auth/firebase_auth.dart';

Future<void> deleteAccount() async {
  final user = FirebaseAuth.instance.currentUser;
  if (user == null) return;

  try {
    await user.delete();
  } on FirebaseAuthException catch (e) {
    if (e.code == 'requires-recent-login') {
      await reauthenticate(user); // ask the user to sign in again
      await user.delete();
    } else {
      rethrow;
    }
  }
}

##3. Re-authenticate

How you re-authenticate depends on the sign-in method. For email and password:

dart
Future<void> reauthenticate(User user) async {
  final password = await askForPassword(); // your own dialog
  final credential = EmailAuthProvider.credential(
    email: user.email!,
    password: password,
  );
  await user.reauthenticateWithCredential(credential);
}

For providers like Apple or Google, run the provider's sign-in flow again and call reauthenticateWithCredential (or reauthenticateWithProvider) with the result.

##4. Delete the user's data on the server

Don't rely on the app to delete Firestore documents and Storage files — the app could be killed mid-way, and client rules shouldn't allow mass deletes anyway. Instead, delete data on the backend when the Auth user is deleted:

  • Use a Cloud Function triggered by Auth user deletion, or Firebase's "Delete User Data" extension, to remove the user's documents and files.
  • Remove push tokens, cancel scheduled jobs, and delete the user in third-party services (analytics user profiles, email lists, RevenueCat customer) where applicable.
  • Log the deletion for your own records without keeping personal data.

##5. Sign in with Apple: revoke tokens

Apple requires apps that offer Sign in with Apple to revoke the user's tokens when they delete their account. With Firebase, the flow is: get a fresh authorization code by having the user sign in with Apple again, then call:

dart
await FirebaseAuth.instance.revokeTokenWithAuthorizationCode(authorizationCode);

Do this before deleting the Firebase user. Check the current FlutterFire docs for your SDK version, as the Apple flow details have evolved.

In Play Console → App content → Data safety, provide a URL where users can request account deletion. A simple page with a form or instructions to email support is acceptable, as long as requests are actually processed.

##7. After deletion

  • Sign the user out locally and clear cached data (secure storage, local database, shared preferences).
  • Navigate to the welcome screen.
  • Show a short confirmation that the account was deleted.

##Testing checklist

  • Delete right after sign-in (no re-auth needed)
  • Delete after a long session (re-auth path)
  • Cancel at the confirmation dialog and the re-auth step
  • Verify data is gone in the database and storage
  • Sign up again with the same email afterwards

This screen belongs in your MVP scope from day one — see the MVP scope template.

##Frequently asked questions

Is account deletion required on the App Store?+

Yes. Apps that support account creation must let users initiate account deletion from within the app.

Can I just deactivate the account instead of deleting it?+

Not as the only option. Deactivation can be offered in addition, but users must be able to delete their account and associated data, apart from data you're legally required to keep.

Does deleting an account cancel the user's subscription?+

No. Subscriptions are managed by Apple or Google. Tell users to cancel in their store subscription settings, and link to it from the deletion screen.