React 本机正确处理放大 Auth.federatedSignIn

React native proper handling of amplify Auth.federatedSignIn

所以我对 React Native 有点陌生,我目前正在尝试为我的应用程序实现 Cognito 社交登录,并且第 3 方登录工作但代码本身不等待成功登录。

我确定我遗漏了一些简单的东西。

const socialSignIn = async (provider: string) => {
  const result = await Auth.federatedSignIn({ provider: provider });

  if (result) {
    setIsSignedIn(true);
  }
};

这是代码块,它打开本机浏览器并为给定的社交登录调出登录页面,登录有效并将重定向回应用程序。但是等待代码已经执行,所以我想知道我应该听什么/检查重定向回应用程序?我知道登录有效,因为下一次调用 federatedSignIn 将 return 凭据

我看到有些人使用 Hub.listen 但我没有运气在重定向回应用程序后调用它。

谢谢

Cognito 流程的这一部分被破坏是因为我错过了文档中说要为 React Native 添加 DeepLinking 的部分。加上对本机反应如何在设备上运行的误解,因此应用程序外部的重定向会终止等待序列。

可以找到here