检查Amazon Cognito角色(Auth vs Unauth)

时间:2016-05-15 07:07:10

标签: ios authentication amazon-web-services aws-lambda amazon-cognito

我是新手使用AWS作为我的iOS移动应用的后端。我已经设置了所需的所有角色和标识池。我已将以下代码添加到AppDelegate.m文件中:

// Starting AWS
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@"IdentityPool"];

AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsProvider];

查看我是否经过身份验证的下一步是什么?试图找出iOS代码,看看我的角色。

AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = configuration;

1 个答案:

答案 0 :(得分:0)

导入要使用AWS的服务标头,然后尝试调用AWS服务。

AWSS3Transfermanager *transferManager = [AWSS3Transfermanager defaultS3TransferManager];
AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
uploadRequest.bucket = yourBucket;
uploadRequest.key = yourKey;
uploadRequest.body = yourDataURL;
uploadRequest.contentLength = [NSNumber numberWithUnsignedLongLong:fileSize];

[[transferManager upload:uploadRequest] continueWithBlock:^id(AWSTask *task) {
    // Do something with the response
    return nil;
}];