#✅ - When I restart app with an AuthUser, why isnt Auth HubPublisher called?

8 messages · Page 1 of 1 (latest)

oblique pine
#

I am using v2 API with swift. When I restart the app, I have a non-nil AuthUser but my listener to Amplify.Hub.publisher(for: .auth) doesn't emit HubPayload.EventName.Auth.signedIn, and when I even try to sign in again, it rightfully says that I can't sign in when an account is already signed in. Why is this behavior going on?

austere robin
#

Are you expecting a HubPayload.EventName.Auth.signedIn to be sent when the app is reopened?

oblique pine
#

@austere robin that would be nice. If I make a change, build and load it on my device, my app restarts and depends on the events from amplify auth publisher to know the state of auth.

#

I dont want to have to manage my own state when it comes to auth

austere robin
#

That's totally understandable. The Hub is designed to dispatch events when they happen, e.g. signedIn is dispatched after the user signs in. For your use case, I recommend using fetchAuthSession() to determine if a user is signed in on app launch. For example:

let isSignedIn = try await Amplify.Auth.fetchAuthSession().isSignedIn
oblique pine
#

cool thanks!

austere robin
#

np! I'm resolving this thread now. Please don't hesitate to open a new one or a GitHub issue if you have any other questions.

thorn plinthBOT
#

✅ - When I restart app with an AuthUser, why isnt Auth HubPublisher called?