Возможно, рассмотрим поле Cognito «username», которое является уникальным идентификатором (неизменяемым) для каждого пользователя:
let amc = AWSMobileClient.sharedInstance();
if (amc.isSignedIn) {
print ("Signed in with username=\(amc.username!)")
}
мы также можем использовать getUserAttributes
для извлечения всех атрибутов следующим образом:
// See all the attributes the user has
amc.getUserAttributes { (attributes, error) in
if let attributes = attributes {
for (key, value) in attributes {
print("\(key): \(value)")
}
} else if let error = error {
print("Unexpected error: \(error.localizedDescription)")
}
}