Skip to content

Definição das atribuições do usuário

Saiba como definir as atribuições do usuário por meio do Braze SDK.

Prerequisites

Before you can use this feature, you’ll need to integrate the Android Braze SDK.

Default user attributes

To set a default attribute for a user, call the getCurrentUser() method on your Braze instance to get a reference to the current user of your app. Then you can call methods to set a user attribute.

Braze provides predefined methods for setting the following user attributes within the BrazeUser class . For method specifications, refer to our KDoc .

  • First name
  • Last name
  • Country
  • Language
  • Date of birth
  • Email
  • Gender
  • Home city
  • Phone number

Custom user attributes

In addition to the default user attributes, Braze also allows you to define custom attributes using several different data types. For more information on each attribute’s segmentation option, see User data collection.

Setting custom attributes

To set a custom attribute with a string value:

To set a custom attribute with an int value:

To set a custom attribute with a long integer value:

To set a custom attribute with a float value:

To set a custom attribute with a double value:

To set a custom attribute with a boolean value:

The maximum number of elements in custom attribute arrays defaults to 25. The maximum for individual arrays can be increased to up to 100 in the Braze dashboard, under Data Settings > Custom Attributes. Arrays exceeding the maximum number of elements will be truncated to contain the maximum number of elements. For more information on custom attribute arrays and their behavior, see our documentation on Arrays.

Unsetting a custom attribute

Custom attributes can also be unset using the following method:

Using the REST API

You can also use our REST API to set or unset user attributes. For more information, refer to User Data Endpoints.

Setting user subscriptions

To set up a subscription for your users (either email or push), call the functions setEmailNotificationSubscriptionType() or setPushNotificationSubscriptionType(), respectively. Both of these functions take the enum type NotificationSubscriptionType as arguments. This type has three different states:

Subscription status Definition
OPTED_IN Subscribed, and explicitly opted in
SUBSCRIBED Subscribed, but not explicitly opted in
UNSUBSCRIBED Unsubscribed and/or explicitly opted out

Setting email subscriptions

Setting push notification subscription

guide/swift/analytics/setting_user_attributes.md developer_ %}

guide/web/analytics/setting_user_attributes.md developer_ %}

guide/unity/analytics/setting_user_attributes.md developer_ %}

guide/unreal_engine/analytics/setting_user_attributes.md developer_ %}

QUÃO ÚTIL FOI ESTA PÁGINA?
New Stuff!