AWSers, 我在IOS swift应用程序中使用AWS Amplify进行身份验证(Cognito)和S3存储。但是,如果应用程序在后台运行了一段时间,而我的应用程序无法获取身份ID,因此无法完成上传,则无法将文件上传到S3。
要复制 重现行为的步骤: 如果用户登录并让应用程序在后台等待几分钟(例如5分钟),则该用户现在无法将文件上传到S3,出现以下错误:
Error: Obtaining an identity id in another thread failed or didn't complete within 5 seconds.
Error: The operation couldn’t be completed. (com.amazonaws.AWSCognitoIdentityErrorDomain error 8.)
因此,用户现在需要注销并重新登录,以便他们可以继续将视频文件上传到s3。
这是我AppDelegate.swift中的内容:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// AWS Id config
let credentialsProvider = AWSCognitoCredentialsProvider(regionType:.USEast1,identityPoolId:config_identityID)
let configuration = AWSServiceConfiguration(region:.USEast1, credentialsProvider:credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
我正在使用AWS Drop-in Auth登录:
func showSignIn() {
// Drop in Auth that handles sign in for users
AWSMobileClient.sharedInstance()
.showSignIn(navigationController: self.navigationController!,
signInUIOptions: SignInUIOptions(
canCancel: false,
logoImage: UIImage(named: "PMA background"),
backgroundColor: UIColor.black)) { (signInState, error) in
//handle results and errors
if let signInState = signInState {
print("logged in!", signInState)
self.getCredentials()
} else {
print("error logging in: \(error!.localizedDescription)")
}
}
}
我希望AWS移动客户端和AWStransferUtility将使用我的刷新令牌来更新我的访问令牌,但事实并非如此。