如标题中所写,是否可以更改 Amazon Cognito 用户的用户名?我在文档中找不到任何内容
最佳答案
可以使用 iOS SDK 通过 updateAttributes
API 调用更新 Cognito 用户的 preferred_username
。但是请注意,您无法修改用户的 username
。引用 AWS 官方文档,
The username value is a separate attribute and not the same as the name attribute. A username is always required to register a user, and it cannot be changed after a user is created.
但是,preferred_username
值确实可以更改,并且根据官方 documentation 提供了使用 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;
}];
我还想声明 iOS SDK 的 AWS API 文档相当少,我建议开发人员阅读 SDK source code有疑问时。
关于ios - 是否可以使用 iOS SDK 在 Amazon Cognito 中更改用户名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55774309/