User object

Prev Next

Initialize user object

Whenever you initialize Insider SDK, you also initialize a new Insider user object. You can set attributes for this object and get this object with the getCurrentUser method.

Insider user object represents the current user of your app. It is the main object you can use for attribution (e.g. age, email, opt-in, etc.).

Method Signature

public InsiderUser getCurrentUser()

Method Example

Insider.Instance.getCurrentUser();
Your title goes here
The values in the method examples are sample values. While implementing these methods, you need to replace them with your own unique variables. Otherwise, the methods will not function properly and might cause discrepancies in user unification.

Set email as user identifier

This method allows you to set the user identifier attribute of your Insider user object for data unification. With this attribute, you can unify your user data within Insider products and reach this user via different channels such as mobile app and web.

Method Signature

public InsiderIdentifiers addEmail(String email)

Method Example

InsiderIdentifiers identifiers = new InsiderIdentifiers();
identifiers.addEmail("sample@mail.com");
identifiers.addPhoneNumber("+1234567");
identifiers.addUserID("CRM-ID");
Insider.Instance.getCurrentUser().login(identifiers);
Your title goes here
All parameter types are required to be String.
Phone numbers must start with a + (plus) sign followed by a country code. The country code should start with a number between 1-9.

Set phone number as user identifier

This method allows you to set the user identifier attribute of your Insider user object for data unification. With this attribute, you can unify your user data within Insider products and reach this user via different channels such as mobile app and web.

Method Signature

public InsiderIdentifiers addPhoneNumber(String phoneNumber)

Method Example

InsiderIdentifiers identifiers = new InsiderIdentifiers();
identifiers.addEmail("mobile@useinsider.com");
identifiers.addPhoneNumber("+901234567");
identifiers.addUserID("CRM-ID");
Insider.Instance.getCurrentUser().login(identifiers);
Your title goes here
All parameter types are required to be String.
Phone numbers are required to start with a + (plus) sign followed by a country code. The country code should start with a number between 1-9.

Set user ID as user identifier

This method allows you to set the user identifier attribute of your Insider user object for data unification. With this attribute, you can unify your user data within Insider products and reach this user via different channels such as mobile app and web.

Method Signature

public InsiderIdentifiers addUserID(String userID)

Method Example

InsiderIdentifiers identifiers = new InsiderIdentifiers();
identifiers.addEmail("mobile@useinsider.com");
identifiers.addPhoneNumber("+901234567");
identifiers.addUserID("CRM-ID");
Insider.Instance.getCurrentUser().login(identifiers);
Your title goes here
All parameter types are required to be String.
Phone numbers are required to start with a + (plus) sign followed by a country code. The country code should start with a number between 1-9.

Set name attribute

This method allows you to set the name attribute for your Insider user object.

ParameterData Type
nameString

Method Signature

public InsiderUser setName(String name)

Method Example

Insider.Instance.getCurrentUser().setName("name");

Set surname attribute

This method allows you to set the surname attribute for your Insider user object.

ParameterData Type
surnameString

Method Signature

public InsiderUser setSurname(String surname)

Method Example

Insider.Instance.getCurrentUser().setSurname("surname");

Set gender attribute

This method allows you to set the gender attribute for your Insider user object. You need to pass InsiderGender enum object as a parameter. 

ParameterEnum values

gender (InsiderGender enum) 

InsiderGenderMale
InsiderGenderFemale
InsiderGenderOther

Method Signature

public InsiderUser setGender(InsiderGender gender)

Method Example

Insider.Instance.getCurrentUser().setGender(InsiderGender.OTHER);

Set age attribute

This method allows you to set the age attribute for your Insider user object.

ParameterData Type

age

Integer

Method Signature

public InsiderUser setAge(int age)

Method Example

Insider.Instance.getCurrentUser().setAge(23);

Set birthday attribute

This method allows you to set the birthday attribute for your Insider user object.

Your title goes here
Data should be set in (YYYY-MM-DD) format.
ParameterData Type
birthdayDate

Method Signature

public InsiderUser setBirthday(Date birthday)

Method Example

Date date = new Date(); 
Insider.Instance.getCurrentUser().setBirthday(date);

Select language attribute

This method allows you to set the language attribute for your Insider user object.

ParameterData Type
languageString

Method Signature

public InsiderUser setLanguage(String language)

Method Example

Insider.Instance.getCurrentUser().setLanguage("language");

Set email opt-in attribute

This method allows you to set the email opt-in (permission) attribute for your Insider user object.

ParameterData Type
emailOptinBoolean

Method Signature

public InsiderUser setEmailOptin(boolean emailOptin)

Method Example

Insider.Instance.getCurrentUser().setEmailOptin(true);

Set SMS opt-in attribute

This method allows you to set the SMS opt-in (permission) attribute for your Insider user object.

ParameterData Type
smsOptinBoolean

Method Signature

public InsiderUser setSMSOptin(boolean smsOptin)

Method Example

Insider.Instance.getCurrentUser().setSMSOptin(true);

Set Whatsapp opt-in attribute

This method allows you to set the WhatsApp opt-in (permission) attribute for your Insider user object.

ParameterData Type
whatsAppOptinBoolean

Method Signature

public InsiderUser setWhatsappOptin(boolean whatsAppOptin)

Method Example

Insider.Instance.getCurrentUser().setWhatsappOptin(true);



Set push opt-in attribute

This method allows you to set the push opt-in (permission) attribute for your Insider user object.

your title goes here
If you pass the value as false, the respective device will not receive any push notifications unless you set the value to true.
ParameterData Type
pushOptinBoolean

Method Signature

public InsiderUser setPushOptin(boolean pushOptin)

Method Example

Insider.Instance.getCurrentUser().setPushOptin(true);

Set location opt-in attribute

This method allows you to set the location opt-in (permission) attribute for your Insider user object.

your title goes here
If you pass the value as false, the respective device will not be targeted for Geofence unless you set the value to true.
ParameterData Type
locationOptinBoolean

Method Signature

public InsiderUser setLocationOptin(boolean locationOptin)

Method Example

Insider.Instance.getCurrentUser().setLocationOptin(true);

Set login attribute

This method allows you to set the login status attribute for your Insider user object.

your title goes here
Once you call this method to assign its value as true, you need to call the logout method to set it to false

Method Signature

public InsiderUser login()

Method Example

InsiderIdentifiers identifiers = new InsiderIdentifiers(); 
identifiers.addEmail("sample@mail.com")
            .addPhoneNumber("+1234567")
            .addUserID("CRM-ID"); 
Insider.Instance.getCurrentUser().login(identifiers);

Set logout attribute

This method allows you to set the login status attribute for your Insider user object.

your title goes here
Once you call assign false for the value for login status, you need to call the login method to set it to true.

Method Signature

public void logout()

Method Example

Insider.Instance.getCurrentUser().logout;

Set logout-reset attribute

Your title goes here
This is an alternative logout method for specific use cases. If you're unsure whether it applies to your setup, please contact your account manager. If you don’t have a special requirement, use the default logout method to avoid user-management issues or unexpected MAU increases.

This method allows you to set the login status attribute for your Insider user object, then disassociate the user from the current device and generate new IID for the current device.

Also, this method allows you to send additional Identifiers to include in the logout process, all additional identifiers (including the currently logged in user) will be disassociated from the current device.

your title goes here
Once you call assign false for the value for login status, you need to call the login method to set it to true.

Method Signature

public void logoutResettingInsiderID(InsiderIdentifiers[] additionalIdentifiers)

Method Example

// Logout the current user only
Insider.Instance.getCurrentUser().logoutResettingInsiderID(null);

// Logout the current user along side additional users
InsiderIdentifiers insiderIdentifiers = new InsiderIdentifiers()
        .addEmail("sample@mail.com")
        .addPhoneNumber("+1234567890")
        .addUserID("CRM-ID");

Insider.Instance.getCurrentUser().logoutResettingInsiderID(new InsiderIdentifiers[]{insiderIdentifiers});

Set sign up event

To trigger action for the signup of users, you need to call this method whenever a user signs up to the app.

Method Signature

public void signUpConfirmation()

Method Example

Insider.Instance.signUpConfirmation();

Set locale attribute

This method allows you to set the locale attribute for your Insider user object.

ParameterData Type
localeString

Method Signature

public InsiderUser setLocale(String locale)

Method Example

Insider.Instance.getCurrentUser().setLocale("en_EN");

Set custom string attribute

This method allows you to set the custom string attribute for your Insider user object.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character, or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueString

Method Signature

public InsiderUser setCustomAttributeWithString(String key, String value)

Method Example

Insider.Instance.getCurrentUser().setCustomAttributeWithString("key", "stringValue");

Set custom integer attribute

This method allows you to set the custom integer attribute for your Insider user object.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character, or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueInteger

Method Signature

public InsiderUser setCustomAttributeWithInt(String key, int value)

Method Example

Insider.Instance.getCurrentUser().setCustomAttributeWithInt("key", 10);

Set custom boolean attribute

This method allows you to set the custom boolean attribute for your Insider user object.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character, or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueBoolean

Method Signature

public InsiderUser setCustomAttributeWithBoolean(String key, boolean value)

Method Example

Insider.Instance.getCurrentUser().setCustomAttributeWithBoolean("key", true);

Set custom double attribute

This method allows you to set the custom double attribute for your Insider user object.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character, or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueDouble

Method Signature

public InsiderUser setCustomAttributeWithDouble(String key, double value)

Method Example

Insider.Instance.getCurrentUser().setCustomAttributeWithDouble("key", 10.5);

Set custom date attribute

This method allows you to set the custom date attribute for your Insider user object.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character, or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueDate object

Method Signature

public InsiderUser setCustomAttributeWithDate(String key, Date value)

Method Example

Date date = new Date();
Insider.Instance.getCurrentUser().setCustomAttributeWithDate("key", date);

Set custom array attribute

This method allows you to set the custom array attribute for your Insider user object.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character, or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueArray (of string)

Method Signature

public InsiderUser setCustomAttributeWithArray(String key, String[] value)

Method Example

String[] myArray = {"value1", "value2", "value3"};
Insider.Instance.getCurrentUser().setCustomAttributeWithArray("key", myArray);

Unset custom attribute

This method allows you to unset any custom attribute of your Insider user object. This method will remove the respective custom attribute of your user for the given key permanently.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character, or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString

Method Signature

public InsiderUser unsetCustomAttribute(String key)

Method Example

Insider.Instance.getCurrentUser().unsetCustomAttribute("key");

For troubleshooting, refer to Why cannot we trigger the login method a second time in an active sessionConfusion of attributes among users after login