AWSCognitoCredentialsProvider クラスのログイン ディクショナリで DeveloperAuthProviderName と Token を送信するオープン ID を使用し、次に viecontroller でラムダ関数を呼び出して、以下のエラーが発生します。CognitoSyncDemo アプリを使用し、ポッドを介してすべてのフレームワークをインポートしようとしましたが、結果は同じです。これから私を助けてください。
AWSiOSSDKv2 [エラー] AWSCredentialsProvider.m line:435 | __73-[AWSCognitoCredentialsProvider getCredentialsWithCognito:認証済み:]_block_invoke | GetCredentialsForIdentity に失敗しました。エラーは [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=7 "操作を完了できませんでした。(com.amazonaws.AWSCognitoIdentityErrorDomain エラー 7.)" UserInfo=0x1700778c0 {__type=InvalidParameterException, message=有効なパブリック プロバイダーを提供してください。 }]
これはAppdelegate.mです
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityId:IdentityId identityPoolId:CognitoIdentityPoolId logins:@{DeveloperAuthProviderName:Token}];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1
credentialsProvider:credentialsProvider];
[[AWSServiceManager defaultServiceManager] setDefaultServiceConfiguration:configuration];
return YES;
}
これは、viewController の viewDidLoad のコードです。
-(void)setUpCredentials{
//initWithRegionType:CognitoRegionType identityId:IdentityId identityPoolId:CognitoIdentityPoolId logins:@{DeveloperAuthProviderName:Token}
AZCDeveoper class inherit AWSEnhancedCognitoIdentityProvider class
AZCDeveloper * identity = [[AZCDeveloper alloc] initWithRegionType:CognitoRegionType identityId:IdentityId accountId:nil identityPoolId:CognitoIdentityPoolId logins:@{DeveloperAuthProviderName:Token}];
credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:CognitoRegionType
identityProvider:identity
unauthRoleArn:nil
authRoleArn:nil];
// [identity refresh];
}
これは、特定のクリックで呼び出されるラムダ関数です
-(void)lamdaInvoker{
AWSLambdaInvoker *lambdaInvoker = [AWSLambdaInvoker defaultLambdaInvoker];
NSLog(@"LamdaInvoker:%@",lambdaInvoker);
[[lambdaInvoker invokeFunction:@"Hello"
JSONObject:@{@"": @""}] continueWithBlock:^id(BFTask *task) {
if (task.error) {
NSLog(@"Error: %@", task.error);
if ([task.error.domain isEqualToString:AWSLambdaInvokerErrorDomain]
&& task.error.code == AWSLambdaInvokerErrorTypeFunctionError) {
NSLog(@"Function error: %@", task.error.userInfo[AWSLambdaInvokerFunctionErrorKey]);
}
}
if (task.exception) {
NSLog(@"Exception: %@", task.exception);
}
if (task.result) {
NSLog(@"Result: %@", task.result);
dispatch_async(dispatch_get_main_queue(), ^{
});
}
return nil;
}];
}