prompt method

void prompt([
  1. PromptMomentListenerFn? momentListener
])

The prompt method displays the One Tap prompt or the browser native credential manager after the initialize method is invoked.

Normally, the prompt method is called on page load. Due to the session status and user settings on the Google side, the One Tap prompt UI might not be displayed. To get notified on the UI status for different moments, pass a PromptMomentListenerFn to receive UI status notifications.

Notifications are fired on the following moments:

  • Display moment: This occurs after the prompt method is called. The notification contains a boolean value to indicate whether the UI is displayed or not.

  • Skipped moment: This occurs when the One Tap prompt is closed by an auto cancel, a manual cancel, or when Google fails to issue a credential, such as when the selected session has signed out of Google. In these cases, we recommend that you continue on to the next identity providers, if there are any.

  • Dismissed moment: This occurs when Google successfully retrieves a credential or a user wants to stop the credential retrieval flow. For example, when the user begins to input their username and password in your login dialog, you can call the cancel method to close the One Tap prompt and trigger a dismissed moment.

    WARNING: When on a dismissed moment, do not try any of the next identity providers.

Method: google.accounts.id.prompt https://developers.google.com/identity/gsi/web/reference/js-reference#google.accounts.id.prompt

Implementation

void prompt([PromptMomentListenerFn? momentListener]) {
  if (momentListener == null) {
    return _prompt();
  }
  return _promptWithListener(momentListener.toJS);
}