User object
  • 06 May 2024
  • 6 Minutes to read

    User object


      Article Summary

      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

      FlutterInsiderUser getCurrentUser()

      Method Example

      FlutterInsider.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

      Future<FlutterInsiderIdentifiers> addEmail(String email) async

      Method Example

      FlutterInsiderIdentifiers identifiers = new FlutterInsiderIdentifiers();
      identifiers.addEmail("sample@mail.com");
      identifiers.addPhoneNumber("+651234567");
      identifiers.addUserID("CRM-ID");
      await FlutterInsider.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.
      Your title goes here
      UCD listens to the IRM settings to distinguish your actual identifiers, so setting the email identifier from the SDK doesn't mean that it will be sent as an identifier.

      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

      Future<FlutterInsiderIdentifiers> addPhoneNumber(String phoneNumber) async

      Method Example

      FlutterInsiderIdentifiers identifiers = new FlutterInsiderIdentifiers();
      identifiers.addEmail("sample@mail.com");
      identifiers.addPhoneNumber("+651234567");
      identifiers.addUserID("CRM-ID");
      await FlutterInsider.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

      Future<FlutterInsiderIdentifiers> addUserID(String userID) async

      Method Example

      FlutterInsiderIdentifiers identifiers = new FlutterInsiderIdentifiers();
      identifiers.addEmail("sample@mail.com");
      identifiers.addPhoneNumber("+651234567");
      identifiers.addUserID("CRM-ID");
      await FlutterInsider.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

      Future setName(String name) async

      Method Example

      FlutterInsider.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

      Future setSurname(String surname) async

      Method Example

      FlutterInsider.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

      Future setGender(int gender) async

      Method Example

      FlutterInsider.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

      Future setAge(int age) async

      Method Example

      FlutterInsider.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

      Future setBirthday(DateTime birthday) async

      Method Example

      FlutterInsider.Instance.getCurrentUser().setBirthday(new DateTime.now());

      Select language attribute

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

      ParameterData Type
      languageString

      Method Signature

      Future setLanguage(String language) async

      Method Example

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

      Set Facebook ID attribute

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

      ParameterData Type
      facebookIDString

      Method Signature

      Future setFacebookID(String facebookID) async

      Method Example

      FlutterInsider.Instance.getCurrentUser().setFacebookID("facebookID");

      Set Twitter ID attribute

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

      ParameterData Type
      twitterIDString

      Method Signature

      Future setTwitterID(String twitterID)

      Method Example

      FlutterInsider.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.

      ParameterData Type
      emailOptinBoolean

      Method Signature

      Future setEmailOptin(bool emailOptin) async

      Method Example

      FlutterInsider.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

      Future setSMSOptin(bool smsOptin) async

      Method Example

      FlutterInsider.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

      Future setWhatsappOptin(bool whatsappOptin) async

      Method Example

      FlutterInsider.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

      Future setPushOptin(bool pushOptin) async

      Method Example

      FlutterInsider.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

      Future setLocationOptin(bool locationOptin) async

      Method Example

      FlutterInsider.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 false

      Method Signature

      Future login(FlutterInsiderIdentifiers identifiers) async

      Method Example

      FlutterInsiderIdentifiers identifiers = new FlutterInsiderIdentifiers();
      identifiers.addEmail("sample@mail.com");
      identifiers.addPhoneNumber("+651234567");
      identifiers.addUserID("CRM-ID");
      await FlutterInsider.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 true.

      Method Signature

      Future logout() async

      Method Example

      FlutterInsider.Instance.getCurrentUser().logout();

      Set signup event

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

      Method Signature

      Future signUpConfirmation() async

      Method Example

      FlutterInsider.Instance.signUpConfirmation()

      Set locale attribute

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

      ParameterData Type
      localeString

      Method Signature

      Future setLocale(String locale) async

      Method Example

      FlutterInsider.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

      Future setCustomAttributeWithString(String key, String value) async

      Method Example

      FlutterInsider.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

      Future setCustomAttributeWithInt(String key, int value) async

      Method Example

      FlutterInsider.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

      Future setCustomAttributeWithBoolean(String key, bool value) async

      Method Example

      FlutterInsider.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

      Future setCustomAttributeWithDouble(String key, double value) async

      Method Example

      FlutterInsider.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

      Future setCustomAttributeWithDate(String key, DateTime value) async

      Method Example

      FlutterInsider.Instance.getCurrentUser().setCustomAttributeWithDate("key", new DateTime.now());

      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

      Future setCustomAttributeWithArray(String key, List value) async

      Method Example

      List<String> arr = new List(3);
          arr[0] = "item1";
          arr[1] = "item2";
          arr[2] = "item3";
      FlutterInsider.Instance.getCurrentUser().setCustomAttributeWithArray("key", arr);

      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.

      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

      Future unsetCustomAttribute(String key) async

      Method Example

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

      Was this article helpful?

      What's Next
      ESC

      Eddy, a super-smart generative AI, opening up ways to have tailored queries and responses