User Profile (Android SDK - Kotlin)
Andrey Veprikov
Update User Profile
Method Objective
The method updates the user's profile or creates a new profile bound to the user's current device if it was not created earlier.
If you don't have user data, never send bogus data. It'll cause problems in profile handling in the future. For example, don't send a non-existent email, like anonymous@example.com
, or an automatically generated email address that doesn't have anything to do with the user's actual email.
Syntax and parameters
sdk.profile(params, callback)
Name | Type | Requirement | Description |
---|---|---|---|
params | HashMap | required | Object with request parameters |
callback | function | optionally | The callback function to which the API response will be passed |
Main request parameters
Name | Type | Description |
---|---|---|
string | User Email. | |
first_name | string | User First Name. |
gender | string | User Gender (m – male, f – female). |
id | string | Store side user ID. |
last_name | string | User Surname. |
phone | string | User Phone. |
Additional request parameters
Name | Type | Description |
---|---|---|
age | string | User age (in years). |
auto | JSON string | List of vehicles. See description below. |
birthday | string | User birthday in the format YYYYY-MM-DD. |
bought_something | string | The user has or hasn't ever bought something in the store. "1" - if the user has made purchases, "0" - if not. |
fb_id | string | Facebook User ID. |
kids | JSON string | User's children. See description below. |
location | string | The user's current location from the list of locations in the product feed. |
loyalty_bonuses | string | The current number of store bonuses at the user. |
loyalty_bonuses_to_next_level | string | The number of store bonuses necessary for the user to reach the next loyalty level. |
loyalty_card_location | string | The location (from the list of locations in the product feed) where the user last used the loyalty card. |
loyalty_id | string | The Loyalty Program user ID (loyalty card). |
loyalty_status | string | The user's current status in the loyalty program. |
telegram_id | string | Telegram User ID. |
vk_id | string | VKontakte User ID. |
The "auto" object properties
Name | Type | Description |
---|---|---|
brand | string | Vehicle Brand. |
model | string | Vehicle Model. |
vds | string | Vehicle's VDS/VIN. |
The "kids" object properties
Name | Type | Description |
---|---|---|
gender | string | Child's age (m – male, f – female). |
birthday | string | Child's birthday in the format YYYY-MM-DD. |
Custom Properties
Name | Type | Description |
---|---|---|
A custom property can have any name except the reserved ones | string | The custom property must be created before it can be used. Located there: Account > Settings > Profile Property If property creation isn't available in the account, contact PersonaClick support. |
integer | ||
float | ||
array of string | ||
json | ||
date (YYYY-MM-DD hh:mm:ss) |
Examples of use
/** * Initializes arrays of basic data types. * These arrays demonstrate that profile properties can support arrays of strings, integers, floats, booleans, and dates. */ val stringArray = arrayOf("item1", "item2", "item3") val intArray = arrayOf(1, 2, 3, 4, 5) val floatArray = arrayOf(1.1f, 2.2f, 3.3f) val boolArray = arrayOf(true, false, true) val dateArray = arrayOf(Date(), Date(), Date()) /** * Creates a nested JSON object. * This object demonstrates how to structure complex data with key-value pairs, including strings and integers. */ val nestedObject = JSONObject().apply { put("nestedStringKey", "nestedValue") put("nestedIntKey", 456) } /** * Creates a custom JSON object. * The object includes various data types such as strings, integers, floats, booleans, dates, arrays, * and even another nested JSON object. */ val customObject = JSONObject().apply { put("stringKey", "stringValue") put("intKey", 123) put("floatKey", 45.67f) put("boolKey", true) put("dateKey", Date()) put("arrayKey", JSONArray(arrayOf(1, 2, 3))) put("nestedObjectKey", nestedObject) } /** * Creates an array of custom JSON objects. * This demonstrates how to pass an array of complex objects as a single profile property. */ val customObjectArray = arrayOf(customObject, customObject) /** * Builds the ProfileParams object using the Builder pattern. * This example demonstrates how to add a wide range of user properties, * including basic data types, arrays, and custom objects, to be passed to the SDK. */ val params = ProfileParams.Builder() .put("userId", 100500) .put("userEmail", "john.doe@examplemail.com") .put("userPhone", "4400114527199") .put("firstName", "John") .put("lastName", "Doe") .put("birthday", "1990-03-11") .put("age", 31) .put("gender", "m") .put("location", "NY") .put("bought_something", true) .put("userLoyaltyId", "000001234567") .put("loyaltyCardLocation", "NY") .put("loyaltyStatus", "5% discount") .put("loyaltyBonuses", 1123) .put("loyaltyBonusesToNextLevel", 1877) .put("fbID", "000000000354677") .put("vkID", "vk031845") .put("telegramId", "0125762968357835") .put("kids", "[{\"gender\":\"m\",\"birthday\":\"2001-04-12\"},{\"gender\": \"f\", \"birthday\": \"2015-07-28\"}]") .put("auto", "[{\"brand\":\"Nissan\",\"model\":\"Qashqai\",\"vds\":\"TM7N243E4G0BJG978\"}]") .put("custom_string_property", "string_value") .put("custom_integer_property", 100500) .put("custom_float_property", 7.62) .put("custom_date_property", "2021-12-31 23:55:00") .put("stringArray", stringArray) .put("intArray", intArray) .put("floatArray", floatArray) .put("boolArray", boolArray) .put("dateArray", dateArray) .put("customObject", customObject) .put("customObjectArray", customObjectArray) /** * Calls the SDK's profile method to save user profile data. * A callback is included to handle success or failure of the API call. */ sdk.profile(params)
val params = ProfileParams.Builder() .put("userId", 100500) .put("userEmail", "john.doe@examplemail.com") sdk.profile(params, object : OnApiCallbackListener() { fun onSuccess(response: JSONObject) { // API response processing functionality } });
Get Device ID of Current Profile
Method Objective
The method allows getting the Device ID of the current profile.
Syntax
sdk.getDid()
Example of use
val deviceId = sdk.getDid()
Page Navigation
Related Pages
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
Related content
Copyright 2018-2024 PersonaClick