- 22 Aug 2023
- 6 Minutes to read
User object
- Updated on 22 Aug 2023
- 6 Minutes to read
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 getCurrentUser method.
Insider user object represents the current user of your app. It is the main object that you can use for attribution (e.g. age, email, opt-in, etc.).
Method Signature
public InsiderUser getCurrentUser()
Method Example
Insider.Instance.getCurrentUser();
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);
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 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);
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);
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.
Parameter | Data Type |
---|---|
name | String |
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.
Parameter | Data Type |
---|---|
surname | String |
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.
Parameter | Enum values |
---|---|
gender (InsiderGender enum) | InsiderGenderMale |
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.
Parameter | Data 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.
Parameter | Data Type |
---|---|
birthday | Date |
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.
Parameter | Data Type |
---|---|
language | String |
Method Signature
public InsiderUser setLanguage(String language)
Method Example
Insider.Instance.getCurrentUser().setLanguage("language");
Set Facebook ID attribute
This method allows you to set the Facebook ID attribute for your Insider user object.
Parameter | Data Type |
---|---|
facebookID | String |
Method Signature
public InsiderUser setFacebookID(String facebookID)
Method Example
Insider.Instance.getCurrentUser().setFacebookID("facebookID");
Set Twitter ID attribute
This method allows you to set the Twitter ID attribute for your Insider user object.
Parameter | Data Type |
---|---|
twitterID | String |
Method Signature
public InsiderUser setTwitterID(String twitterID)
Method Example
Insider.Instance.getCurrentUser().setTwitterID("twitterID");
Set email opt-in attribute
This method allows you to set the email opt-in (permission) attribute for your Insider user object.
Parameter | Data Type |
---|---|
emailOptin | Boolean |
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.
Parameter | Data Type |
---|---|
smsOptin | Boolean |
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.
Parameter | Data Type |
---|---|
whatsAppOptin | Boolean |
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.
Parameter | Data Type |
---|---|
pushOptin | Boolean |
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.
Parameter | Data Type |
---|---|
locationOptin | Boolean |
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.
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.
Method Signature
public void logout()
Method Example
Insider.Instance.getCurrentUser().logout;
Set sign up event
To trigger action for signup of users, you need to call this method whenever a user sign 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.
Parameter | Data Type |
---|---|
locale | String |
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.
Parameter | Data Type |
---|---|
key | String |
value | String |
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.
Parameter | Data Type |
---|---|
key | String |
value | Integer |
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.
Parameter | Data Type |
---|---|
key | String |
value | Boolean |
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.
Parameter | Data Type |
---|---|
key | String |
value | Double |
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.
Parameter | Data Type |
---|---|
key | String |
value | Date 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.
Parameter | Data Type |
---|---|
key | String |
value | Array (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 the custom attribute of your user for the given key permanently.
Parameter | Data Type |
---|---|
key | String |
Method Signature
public InsiderUser unsetCustomAttribute(String key)
Method Example
Insider.Instance.getCurrentUser().unsetCustomAttribute("key");