I am following along with AWS Amplify documentation and the example code given to check the current auth session is
func fetchCurrentAuthSession() {
_ = Amplify.Auth.fetchAuthSession { (result) in
switch result {
case .success(let session):
print("Is user signed in - \(session.isSignedIn)")
case .failure(let error):
print("Fetch session failed with error \(error)")
}
}
}
after calling this func in a viewDidLoad I get this error Thread 1: Fatal error: Authentication category is not configured. Call Amplify.configure() before using any methods on the category. So I then changed the code to this
func fetchCurrentAuthSession() {
do {
try Amplify.configure()
_ = Amplify.Auth.fetchAuthSession { (result) in
switch result {
case .success(let session):
print("Is user signed in - \(session.isSignedIn)")
case .failure(let error):
print("Fetch session failed with error \(error)")
}
}
}catch{
}
}
It runs with no errors but the authSession is not printed. What is the proper way to fix this? here is the link to their docs https://docs.amplify.aws/lib/auth/getting-started/q/platform/ios#check-the-current-auth-session
Here is my awsconfiguration.json
{
"UserAgent": "aws-amplify/cli",
"Version": "0.1.0",
"IdentityManager": {
"Default": {}
},
"CredentialsProvider": {
"CognitoIdentity": {
"Default": {
"PoolId": "removed",
"Region": "removed"
}
}
},
"CognitoUserPool": {
"Default": {
"PoolId": "removed",
"AppClientId": "removed",
"AppClientSecret": "removed",
"Region": "removed"
}
},
"FacebookSignIn": {
"AppId": "removed",
"Permissions": "public_profile"
},
"Auth": {
"Default": {
"authenticationFlowType": "USER_SRP_AUTH"
}
}
}
Here is my amplifyconfiguration.json
{
"UserAgent": "aws-amplify-cli/2.0",
"Version": "1.0"
}