new User()
Members
-
<static, readonly> Genders :string
-
Enum to represent valid genders.
Type:
- string
Properties:
Name Type Default Description MALEstring m FEMALEstring f OTHERstring o -
<static, readonly> NotificationSubscriptionTypes :string
-
Enum to represent notification status for email and push notifications.
Type:
- string
Properties:
Name Type Default Description OPTED_INstring opted_in SUBSCRIBEDstring subscribed UNSUBSCRIBEDstring 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 keystring The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.
valuestring 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 keystring The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.
incrementValueinteger <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 keystring The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.
valuestring 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 avatarImageUrlstring Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setCountry(country) → {boolean}
-
Sets the country for the user.
Parameters:
Name Type Description countrystring 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 keystring The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.
valueCan 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 yearinteger monthinteger 1-12
dayinteger Returns:
Whether the update was successfully enqueued.
- Type
- boolean
-
setEmail(email) → {boolean}
-
Sets the email address of the user.
Parameters:
Name Type Description emailstring 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 notificationSubscriptionTypeab.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 firstNamestring 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 genderab.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 homeCitystring 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 latitudefloat The latitude of the user's location in (valid values are between -90 to 90 degrees)
longitudefloat The longitude of the user's location (valid values are between -180 to 180 degrees)
accuracyfloat <optional>
The accuracy of the user's lat/long in meters.
altitudefloat <optional>
The altitude of the user's location in meters above or below the WGS 84 reference ellipsoid.
altitudeAccuracyfloat <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 lastNamestring 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 phoneNumberstring 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 notificationSubscriptionTypeab.User.NotificationSubscriptionTypes Notification setting (explicitly opted-in, subscribed, or unsubscribed).
Returns:
Whether the update was successfully enqueued.
- Type
- boolean