resendSignUpCode method

Future<ResendSignUpCodeResult> resendSignUpCode({
  1. required String username,
  2. ResendSignUpCodeOptions? options,
})

Resends the code that is used to confirm the user's account after sign up.

username must be the same as the value passed to signUp and is either an identifier chosen by the user or their email/phone number, depending on the configuration.

Optionally accepts plugin options which allow customizing provider-specific behavior, e.g. the Cognito User Pool.

Examples

import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
Future<void> resendSignUpCode(String username) async {
  try {
    final result = await Amplify.Auth.resendSignUpCode(
      username: username,
    );
    final codeDeliveryDetails = result.codeDeliveryDetails;
    _handleCodeDelivery(codeDeliveryDetails);
  } on AuthException catch (e) {
    safePrint('Error resending code: ${e.message}');
  }
}

Prompt the user to check the destination of the delivered code by examining the returned AuthCodeDeliveryDetails object.

void _handleCodeDelivery(AuthCodeDeliveryDetails codeDeliveryDetails) {
  safePrint(
    'A confirmation code has been sent to ${codeDeliveryDetails.destination}. '
    'Please check your ${codeDeliveryDetails.deliveryMedium.name} for the code.',
  );
}

Implementation

Future<ResendSignUpCodeResult> resendSignUpCode({
  required String username,
  ResendSignUpCodeOptions? options,
}) =>
    identifyCall(
      AuthCategoryMethod.resendSignUpCode,
      () => defaultPlugin.resendSignUpCode(
        username: username,
        options: options,
      ),
    );