aws-amplify / aws-sdk-ios

AWS SDK for iOS. For more information, see our web site:
https://aws-amplify.github.io/docs
Other
1.67k stars 877 forks source link

User not signed in after reopening app using new sdk initializer #1939

Closed JesusMartinAlonso closed 4 years ago

JesusMartinAlonso commented 4 years ago

Describe the bug I'm using the new initializer released in 2.11.0 (https://github.com/aws-amplify/aws-sdk-ios/releases/tag/2.11.0). The app seems to work properly (users can sign in) but if the app is closed and reopened again, the user is not signed in (AWSMobileClient.default().isSignedIn returns false). However, I expect to be true

To Reproduce Steps to reproduce the behavior:

  1. In didFinishLaunchingWithOptions method initialize AWSMobileClient using new initializer:
     _  = AWSMobileClient.init(configuration: awsconfigurationDictionary)
  1. Sign in with an user using cognito user pools: AWSMobileClient.default().signIn(username: username, password: password)

  2. Close app

  3. Reopen app, and call AWSMobileClient.default().isSignedIn. This returns false but I expect true

Which AWS service(s) are affected?

Cognito, AWSAmplify

Expected behavior I expect user to be signed in after closing and reopening the app

Environment(please complete the following information):

Device Information (please complete the following information):

royjit commented 4 years ago

Hi @JesusMartinAlonso Did you call AWSMobileClient.default().initialize? As shown here you need to call initialize after init.

 _  = AWSMobileClient.init(configuration: awsconfigurationDictionary)
AWSMobileClient.default().initialize { (userState, error) in
    // initialization logic
}  

Please let us know if this fixes the issue.

JesusMartinAlonso commented 4 years ago

Yes. It seems to work well. Thank you!