2016-12-16 32 views
0

我正在尝试为Android中的AWS Cognito开发歌曲。我刚刚检查了official doc,但在注册一个新用户部分只有使用SignUpHandler的样本。在AWS Cognito上注册一个新的用户,使用Android上的Mobile SDK

enter image description here

检查其他部分,例如Using the JavaScript SDK存在使用 userPool.signUp('username', 'password', attributeList, null, function(err, result)

进出口试图实现此形式给出transpolating的JavaScript示例的明确样品。但我想知道是否有完整的Android注册示例?

在此先感谢!

回答

2

您注意到的处理程序是注册调用的参数,非常类似于JS示例中的“function(err,result)”。看看this part of the docs,它显示了如何使用该处理程序。从你screenshotted的例子中,它可能是这样的:

userPool.signUpInBackground(userId, password, userAttributes, null, handler); 
+0

嗨杰夫感谢您的回答。该示例在步骤3:为用户注册您的应用程序。 –

0

下面是使用由杰夫sugested的link一个完整的示例:

CognitoUserAttributes attributes = new CognitoUserAttributes(); 
    attributes.addAttribute("phone_number","+15555555555"); 
    attributes.addAttribute("email","[email protected]omain.com"); 

    cognitoUserPool.signUp('username', 'password', attributes, null, new SignUpHandler() { 
     @Override 
     public void onSuccess(CognitoUser cognitoUser, boolean b, CognitoUserCodeDeliveryDetails cognitoUserCodeDeliveryDetails) { 
      // If the sign up was successful, "user" is a CognitoUser object of the user who was signed up. 
      // "codeDeliveryDetails" will contain details about where the confirmation codes will be delivered. 
     } 

     @Override 
     public void onFailure(Exception e) { 
      // Sign up failed, code check the exception for cause and perform remedial actions. 
     } 
    }); 

的部分使用用户池与移动SDK的例子对于Android似乎已过时。

希望能帮助别人;)