You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been trying to implement the aws sdk for swift, to use it in my ios app, to verify photos for nudity.
I did the methods that get the credentials:
@MainActorfunc authenticateWithCognito(idToken:String?)asyncthrows->Bool{
guard let idToken = idToken else{print("ID Token is null")throwAuthenticationError.idTokenNull
}letcognitoClient=tryCognitoIdentityClient(region: REGION)letgetIdRequest=GetIdInput(
identityPoolId: IDENTITY_POOL_ID,
logins:[PROVIDER_NAME: idToken])do{letidentityResponse=tryawait cognitoClient.getId(input: getIdRequest)
guard let identityId = identityResponse.identityId else{throwAuthenticationError.failedToRetrieveIdentityId
}
awsCredentials =tryawaitgetAwsCredentials(identityPoolId: IDENTITY_POOL_ID, idToken: idToken, region: REGION)return true
}catch{leterrorMessage= error.localizedDescription.lowercased()
if !errorMessage.isEmpty,
errorMessage.contains("notauthorizedexception"){print("Token expired or invalid, refreshing Firebase token")letnewToken=tryawaitrefreshFirebaseTokenAndAuthenticate()returntryawaitauthenticateWithCognito(idToken: newToken)}else{print("Error during Cognito authentication: \(error.localizedDescription)")throwAuthenticationError.cognitoAuthenticationFailed(error.localizedDescription)}}}
, but the issue is that I cannot find a way to use them in RekognitionClient, something like this:
@MainActorfunc startPhotoRekognition(isImageFromGallery:Bool, sourceImage:UIImage)asyncthrows->Bool{
guard let imageData = sourceImage.jpegData(compressionQuality: 0.8)else{throwPhotoRekognitionError.imageProcessingFailed
}letrekognitionClient=RekognitionClient(
credentialsProvider: credentialsProvider,
region: REGION
)letdetectModerationLabelsRequest=DetectModerationLabelsInput(
image:RekognitionClientTypes.Image(bytes: imageData),
minConfidence:90)letresponse=tryawait rekognitionClient.detectModerationLabels(input: detectModerationLabelsRequest)
if let labels = response.moderationLabels, !labels.isEmpty {return false
}else{return true
}}
due to the fact that RekognitionClient does not provide any way to take them.
I've tried to find a solution, but all I've got was: AwsClient, AwsRekognition, etc, which are not recognised by the library anymore.
How should I put the credentials in the RekognitionClient?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Good evening,
I've been trying to implement the aws sdk for swift, to use it in my ios app, to verify photos for nudity.
I did the methods that get the credentials:
, but the issue is that I cannot find a way to use them in RekognitionClient, something like this:
due to the fact that RekognitionClient does not provide any way to take them.
I've tried to find a solution, but all I've got was: AwsClient, AwsRekognition, etc, which are not recognised by the library anymore.
How should I put the credentials in the RekognitionClient?
Thank you,
Oana
Beta Was this translation helpful? Give feedback.
All reactions