Google has recently announced its deprecation of its Google Sign-In for Websites library. They will be transitioning to the new Sign In With Google SDK for the Web in 2023. The new SDK requires less effort to set up, but I find there are fewer settings available for configuration.
One of the configurations that I am missing is the detection for user closing the One Tab Sign In Pop up. Previously, when the user manually closes the Sign In modal, the library returns the popup_closed_by_user error code. But I am not able to find any detection for this on the new JavaScript Web SDK.
Is there a way to detect the manual pop up closing on the Sign In With Google SDK? I am also interested on detecting "Exponential cooldown". That is, when user has closed the pop-up multiple times and Google SDK won't show the login button on the screen. Is it possible to trigger a callback when this case occurs?
Yes, you can observe the outcome using the PromptMomentNotification object, using the data-moment_callback when rendering the button in HTML or by throught the notification returned by google.accounts.id.prompt.
One tap can be closed a couple of ways, so the older popup_closed_by_user is now best handled by looking at two values:
user_cancel or tap_outside. The former is a result of pressing the X in the dialog or cancel button if present, while the latter is from simply clicking outside of the popup dialog. Both terminate the sign-in flow, the two values allow you to see if user behavior differs. Some users might click elsewhere, while others may explicitly close the popup.