gpt4 book ai didi

ios - 在我的iOS应用中配置Amazon Mobile Analytics和AWS Cognito会引发一些与IAM链接的异常

转载 作者:行者123 更新时间:2023-12-01 17:51:08 27 4
gpt4 key购买 nike

这是我得到的错误:

AWSiOSSDKv2 [Error] AWSMobileAnalyticsDefaultDeliveryClient.m line:282 | -[AWSMobileAnalyticsDefaultDeliveryClient submitEvents:andUpdatePolicies:] | Unable to successfully deliver events to server. Response code: 0. Error Message:Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=6 The operation couldn’t be completed.

I have AuthRole in IAM with the following policy:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"mobileanalytics:PutEvents",
"cognito-sync:*"
],
"Resource": [
"*"
]
}
]
}

还有一个Unauth角色:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"mobileanalytics:PutEvents",
"cognito-sync:*"
],
"Resource": [
"*"
]
}
]
}

IAM中 cognito-identity.amazonaws.com:aud下的字符串提及条件与我的应用程序中声明的匹配。

我不知道问题出在哪里。

编辑

设置代码(快速)。
private func _configureAWSServiceManager() {
let credentialsProvider = AWSCognitoCredentialsProvider(
regionType: Config().amazonRegionType,
identityPoolId: Config().amazonCognitoIdentityPool)
let configuration =
AWSServiceConfiguration(region: Config().amazonRegionType,
credentialsProvider: credentialsProvider)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration =
configuration
}

private func _configureMobileAnalytics() {
let mobileAnalyticsConfiguration = AWSMobileAnalyticsConfiguration()
mobileAnalyticsConfiguration.transmitOnWAN = true;

let analytics = AWSMobileAnalytics(
forAppId: Config().amazonMobileAnalyticsAppId,
configuration: mobileAnalyticsConfiguration,
completionBlock: nil)
_analytics = analytics
}

两者都在 application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)函数的AppDelegate中依次调用。

编辑/解决方案:在再次检查后,发现创建Cognito Identity Pool的步骤确实创建了一个角色,但是没有在 unauthenticated role中分配此角色……很愚蠢,与AWS上的正确管理一样。

最佳答案

问题与CognitoIdentity有关,而不与MobileAnalytics有关。根据该文档,AWSCognitoIdentityErrorDomain Code = 6表示 InvalidIdentityPoolConfiguration

“身份池没有与给定身份验证类型(auth / unauth)或AssumeRole失败相关的角色。”

我的建议是登录到AWS Web Console-> Cognito,再次检查您的身份池的设置。并确保RegionType与您在Web控制台中创建的(在屏幕的右上方)匹配:CognitoIdentity当前支持 us-east-1 eu-west-1

对于MobileAnalytics,请确保仅将configuration.serviceConfiguration.regionType设置为 us-east-1

http://docs.aws.amazon.com/AWSiOSSDK/latest/Constants/AWSCognitoIdentityErrorType.html

关于ios - 在我的iOS应用中配置Amazon Mobile Analytics和AWS Cognito会引发一些与IAM链接的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30186613/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com