Fab*_*zio 6 ios amazon-cognito
如标题中所述,是否可以更改 Amazon Cognito 用户的用户名?我在文档中找不到任何内容
Ark*_*jee 10
可以preferred_username使用 iOS SDK 使用updateAttributesAPI 调用更新Cognito 用户的。但是,请注意,您将无法修改username用户的 。引用官方 AWS 文档,
username 值是一个单独的属性,与 name 属性不同。注册用户始终需要用户名,并且在创建用户后无法更改。
但是,该preferred_username值确实可以更改,使用iOS SDK更改首选用户名的示例代码,根据官方文档说明如下:
AWSCognitoIdentityUserAttributeType * attribute = [AWSCognitoIdentityUserAttributeType new];
attribute.name = @"preferred_username";
attribute.value = @"John User";
[[user updateAttributes:@[attribute]] continueWithSuccessBlock:^id _Nullable(AWSTask<AWSCognitoIdentityUserUpdateAttributesResponse *> * _Nonnull task) {
//success
return nil;
}];
Run Code Online (Sandbox Code Playgroud)
我还想声明 iOS SDK 的 AWS API 文档相当少,我建议开发人员在有疑问时查看SDK 源代码。