我尝试通过在iOS 8 Swift应用程序的应用程序委托中添加以下代码片段来初始化以创建默认服务配置。
按照亚马逊教程here的指示,我使用以下代码行:
//AWS Service Config
let credentialsProvider = AWSCognitoCredentialsProvider(
regionType: AWSRegionType.USEast1, identityPoolId: "us-east-13453454-92d1-234234-234234-3434")
let defaultServiceConfiguration = AWSServiceConfiguration(
region: AWSRegionType.USEast1, credentialsProvider: credentialsProvider)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = defaultServiceConfiguration
但是代码不能编译,因为xCode说我“在Call中缺少参数'identityId'的参数”
首先,这段代码直接来自亚马逊的教程,而且我没有identiyID,只有一个identitypoolid(在我的代码中被扰乱)。
我该怎么做才能解决这个问题?
答案 0 :(得分:0)
我不确定您使用的是正确的初始化程序,请尝试 -
let credentialsProvider = AWSCognitoCredentialsProvider.credentialsWithRegionType(
AWSRegionType.USEast1,
accountId: cognitoAccountId,
identityPoolId: cognitoIdentityPoolId,
unauthRoleArn: cognitoUnauthRoleArn,
authRoleArn: nil)
let defaultServiceConfiguration = AWSServiceConfiguration(region: AWSRegionType.USEast1, credentialsProvider: credentialsProvider)
AWSServiceManager.defaultServiceManager().setDefaultServiceConfiguration(defaultServiceConfiguration)
答案 1 :(得分:0)
let cognitoIdentityPoolId = "us-east-XXXXXXXX"
{
let credentialsProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: cognitoIdentityPoolId)
let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialsProvider)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration