Integration Code Field Guide - Android

Depending on your schema, your integration code will have a variety of commands to call in your SDK. This article covers each command option and what they represent.

Register

Registering an object is how you relate your application data with the schema you had created.

registerUser
Mandatory - Registers your users and associated fields

registerInteraction
Mandatory - Registers your users’ interactions with your content.

registerObject
Optional - Registers any content within your software, such as features, articles, merchandise, etc.

💡
IMPORTANT NOTE: All objects and fields will need to be defined in the schema in order for these calls to work. You can read more about schema definitions in Generate A Schema.

Session

Starting and finishing a user session allows a better understanding of what your user did on your application

startSession()
Requires a user to be registered before. Starts a new session

endSession()
End the most recent open session

💡
IMPORTANT NOTE: Begin AI takes care of mapping the session duration. The Session object is available by default on the schema and cannot be modified.

Add Field

The add*Field relates to the different field values within your schema (username, genre, author, last sign-in, date of birth, etc). They’re broken down as:

for labels:
addLabel(*)
Enables the addition of labels to users and objects
Example: beginWorker.addLabel("book", "object_id", "label");

for user:
updateUserTextField(*)
for object:
updateObjectTextField(*)
Related to text-based entries in your schema (for example: names, bios, posts, etc)
 
Example: updateObjectTextField("book", "1", "bio", "my bio");

for user:
updateUserCategoryField(*)
for object:
updateObjectCategoryField(*)
Related to categorical entries in your schema (for example: type, genre etc)
 
Example: updateObjectCategoryField("book", "1", "genre", "fiction");

for user:
updateUserNumericalField(*)
for object:
updateObjectNumericalField(*)
Relates to numerical entries in your schema (for example: phone numbers, ISBN codes, etc)
 
Example: updateObjectNumericalField("book", "1", "ratings_count", 33);

for user:
updateUserBooleanField(*)
for object:
updateObjectBooleanField(*)
Relates to boolean entries (for example, active/inactive, true/false, etc)
 
Example: updateUserBooleanField("is_admin", true);

updateLocationField(*)
Relates to latitude/longitude co-ordinates in your schema.
 
Example: updateLocationField("location", new LocationModel(33.123, 32.110));

for user:
updateUserDateField(*)
for object:
updateObjectDateField(*)
Refers to date fields in your schema. (dd-mm-yyyy format)
 
Example: updateUserDateField("date_of_birth", "17", "04", "1987");

Each call will follow the source key, source id, and value in parenthesis. For example, if under the “book” object a “book title” field is present, a call will be available for:
beginWorker.updateObjectTextField("book", "1", "genre", "fiction");

Learn

learnFromData call will generate an anonymized signature using the registered content and submit it to Begin AI’s servers for learning.