共用方式為


原生驗證 SDK 屬性建立器

適用於具有灰色 X 符號的白色圓圈。 員工租用戶 具有白色核取記號的綠色圓圈。 外部租用戶 (深入瞭解)

在原生驗證中,您在註冊期間從使用者收集的資訊會設定在 Microsoft Entra 系統管理中心的使用者流程中。 Microsoft Entra 系統管理中心中顯示的使用者屬性名稱與您在應用程式中參考時所使用的變數名稱不同。

幸運的是,原生驗證 SDK 可讓您建置使用者屬性,並在 SDK signUp() 方法中使用它們之前,將值指派給他們。

建置使用者屬性

若要在 Android SDK 中建置使用者屬性:

  • 使用 SDK 提供的公用程式類別 UserAttribute.BuilderUserAttributes.Builder 類別包含方法,其參數是您從使用者收集的值。

  • 識別您想要建置的使用者屬性,然後使用下列程式碼片段來建置它們:

        //build the user attributes, both built-in and custom attributes
        val userAttributes = UserAttributes.Builder()
            .country(country)
            .city(city)
            .displayName(displayName)
            .givenName(givenName)
            .jobTitle(jobTitle)
            .postalCode(postalCode)
            .state(state)
            .streetAddress(streetAddress)
            .surname(surname)
            .build() 
    
        CoroutineScope(Dispatchers.Main).launch {
            //use the userAttributes variable in your signUp method 
            val actionResult = authAuthClientInstance.signUp(
                username = emailAddress,
                attributes = userAttributes
            )
        }  
    
  • 若要建置 自訂屬性,請使用 UserAttribute.Builder類別customAttribute() 方法。 方法會接受自訂屬性的可程式化名稱,以及屬性的值:

       val userAttributes = UserAttributes.Builder()
           .customAttribute("extension_2588abcdwhtfeehjjeeqwertc_loyaltyNumber", loyaltyNumber)
           .build() 
    
       CoroutineScope(Dispatchers.Main).launch {
           //use the userAttributes variable in your signUp method 
           val actionResult = authAuthClientInstance.signUp(
               username = emailAddress,
               attributes = userAttributes
           )
       }  
    

若要深入瞭解使用者設定檔屬性的可程式化名稱,請參閱 使用者設定檔屬性 一文。