Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

認証イベントのリスン

Amplify Auth は認証フロー中にイベントを発行します。これにより、ユーザーフローをリアルタイムで監視し、カスタムビジネスロジックをトリガーできます。たとえば、データをキャプチャし、アプリの状態を同期し、ユーザーエクスペリエンスをパーソナライズしたい場合があります。サインインやサインアウトなど、Auth ライフサイクル全体のイベントをリスンして対応できます。

AWS Cognito Auth プラグインは、Amplify Hub を通じて重要なイベントを送信します。次のようにこれらのイベントをリスニングできます:

final subscription = Amplify.Hub.listen(HubChannel.Auth, (AuthHubEvent event) {
switch (event.type) {
case AuthHubEventType.signedIn:
safePrint('User is signed in.');
break;
case AuthHubEventType.signedOut:
safePrint('User is signed out.');
break;
case AuthHubEventType.sessionExpired:
safePrint('The session has expired.');
break;
case AuthHubEventType.userDeleted:
safePrint('The user has been deleted.');
break;
}
});