new User()
Members
-
<static, readonly> Genders :string
-
Enum to represent valid genders.
Type:
- string
Properties:
Name Type Default Description MALE
string m FEMALE
string f OTHER
string o -
<static, readonly> NotificationSubscriptionTypes :string
-
Enum to represent notification status for email and push notifications.
Type:
- string
Properties:
Name Type Default Description OPTED_IN
string opted_in SUBSCRIBED
string subscribed UNSUBSCRIBED
string unsubscribed
Methods
-
addToCustomAttributeArray(key, value) → {boolean}
-
Adds a string to a custom atttribute string array, or creates that array if one doesn't exist.
Parameters:
Name Type Description key
string The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
a $, and can only contain alphanumeric characters and punctuation.value
string The string to be added to the array. Strings are limited to 255 characters in length, cannot
begin with a $, and can only contain alphanumeric characters and punctuation.Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
getUserId() → {string}
-
Returns:
The currently tracked user id. Returns null if the user is anonymous / has not been identified.
- Type
- string
-
incrementCustomUserAttribute(key, incrementValue) → {boolean}
-
Increment/decrement the value of a custom attribute. Only numeric custom attributes can be incremented. Attempts to
increment a custom attribute that is not numeric be ignored. If you increment a custom attribute that has not
previously been set, a custom attribute will be created and assigned the value of incrementValue. To decrement
the value of a custom attribute, use a negative incrementValue.Parameters:
Name Type Argument Default Description key
string The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
a $, and can only contain alphanumeric characters and punctuation.incrementValue
integer <optional>
1 May be negative to decrement.
Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
removeFromCustomAttributeArray(key, value) → {boolean}
-
Removes a string from a custom attribute string array.
Parameters:
Name Type Description key
string The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
a $, and can only contain alphanumeric characters and punctuation.value
string The string to be removed from the array. Strings are limited to 255 characters in length,
cannot beging with a $, and can only contain alphanumeric characters and punctuation.Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setAvatarImageUrl(avatarImageUrl) → {boolean}
-
Sets the url for the avatar image for the user, which will be displayed on the user profile and throughout the Appboy
dashboard.Parameters:
Name Type Description avatarImageUrl
string Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setCountry(country) → {boolean}
-
Sets the country for the user.
Parameters:
Name Type Description country
string Limited to 255 characters in length.
Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setCustomUserAttribute(key, value) → {boolean}
-
Sets a custom user attribute. This can be any key/value pair and is used to collect extra information about the
user.Parameters:
Name Type Description key
string The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
a $, and can only contain alphanumeric characters and punctuation.value
Can be numeric, boolean, a Date object, a string, or an array of strings. Strings are limited to
255 characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.
Passing a null value will remove this custom attribute from the user.Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setDateOfBirth(year, month, day) → {boolean}
-
Sets the date of birth of the user.
Parameters:
Name Type Description year
integer month
integer 1-12
day
integer Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setEmail(email) → {boolean}
-
Sets the email address of the user.
Parameters:
Name Type Description email
string Must pass RFC-5322 email address validation.
Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setEmailNotificationSubscriptionType(notificationSubscriptionType) → {boolean}
-
Sets whether the user should be sent email campaigns.
Parameters:
Name Type Description notificationSubscriptionType
ab.User.NotificationSubscriptionTypes Notification setting (explicitly
opted-in, subscribed, or unsubscribed).Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setFirstName(firstName) → {boolean}
-
Sets the first name of the user.
Parameters:
Name Type Description firstName
string Limited to 255 characters in length.
Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setGender(gender) → {boolean}
-
Sets the gender of the user.
Parameters:
Name Type Description gender
ab.User.Genders Generally 'm' or 'f'.
Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setHomeCity(homeCity) → {boolean}
-
Sets the home city for the user.
Parameters:
Name Type Description homeCity
string Limited to 255 characters in length.
Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setLastKnownLocation(latitude, longitude, accuracy, altitude, altitudeAccuracy) → {boolean}
-
Sets the last known location for the user.
Parameters:
Name Type Argument Description latitude
float The latitude of the user's location in (valid values are between -90 to 90 degrees)
longitude
float The longitude of the user's location (valid values are between -180 to 180 degrees)
accuracy
float <optional>
The accuracy of the user's lat/long in meters.
altitude
float <optional>
The altitude of the user's location in meters above or below the WGS 84 reference
ellipsoid.altitudeAccuracy
float <optional>
The accuracy of the user's altitude in meters.
Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setLastName(lastName) → {boolean}
-
Sets the last name of the user.
Parameters:
Name Type Description lastName
string Limited to 255 characters in length.
Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setPhoneNumber(phoneNumber) → {boolean}
-
Sets the phone number of the user.
Parameters:
Name Type Description phoneNumber
string A phone number is considered valid if it is no more than 255 characters in length and
contains only numbers, whitespace, and the following special characters +.-()Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setPushNotificationSubscriptionType(notificationSubscriptionType) → {boolean}
-
Sets whether the user should be sent push campaigns.
Parameters:
Name Type Description notificationSubscriptionType
ab.User.NotificationSubscriptionTypes Notification setting (explicitly
opted-in, subscribed, or unsubscribed).Returns:
Whether the update was successfully enqueued.
- Type
- boolean