可以使用iOS SDK在Amazon Cognito中更改用户名吗? [英] Is it possible change username in Amazon Cognito with iOS SDK?

查看:45
本文介绍了可以使用iOS SDK在Amazon Cognito中更改用户名吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以更改Amazon Cognito用户的用户名?我在文档中找不到任何内容

as written in the title is it possible change username of a Amazon Cognito user? I can't find anything in documentation

推荐答案

可以使用 updateAttributes 使用iOS SDK更新Cognito用户的 preferred_username .API调用.但是,请注意,您将无法修改用户的 username .引用AWS官方文档

It is possible to update the preferred_username of a Cognito User using the iOS SDK, using the updateAttributes API call. However, kindly note that you would not be able to modify the username of a user. Quoting the official AWS documentation,

用户名值是一个单独的属性,与名称属性.始终需要用户名才能注册用户,并且创建用户后便无法更改.

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 的值,并可以使用示例代码来使用iOS SDK根据官方

But, the preferred_username value can indeed be changed, and a sample code to change the preferred username using the iOS SDK, as per the official documentation is stated as follows:

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文档非常少,我建议开发人员仔细阅读

I would also like to state that the AWS API documentations for the iOS SDK are rather minimal, and I would recommend developers to go through the SDK source code whenever in doubt.

这篇关于可以使用iOS SDK在Amazon Cognito中更改用户名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆