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.
The 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
+(InsiderUser *)getCurrentUser;Method Examples
[Insider getCurrentUser];Insider.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
-(InsiderIdentifiers *(^)(NSString *))addEmail; Method Examples
InsiderIdentifiers *insiderIdentifiers = [[InsiderIdentifiers alloc] init];
insiderIdentifiers.addEmail(@"sample@mail.com")
.addPhoneNumber(@"+1234567")
.addUserID(@"CRM-ID");
[[Insider getCurrentUser] login:insiderIdentifiers];let identifiers = InsiderIdentifiers()
identifiers.addEmail()("sample@mail.com")?
.addPhoneNumber()("+1234567")?
.addUserID()("CRM-ID")
Insider.getCurrentUser().login(identifiers)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
-(InsiderIdentifiers *(^)(NSString *))addPhoneNumber; Method Examples
InsiderIdentifiers *insiderIdentifiers = [[InsiderIdentifiers alloc] init];
insiderIdentifiers.addEmail(@"mobile@useinsider.com")
.addPhoneNumber(@"+901234567")
.addUserID(@"CRM-ID");
[[Insider getCurrentUser] login:insiderIdentifiers];let identifiers = InsiderIdentifiers()
identifiers.addEmail()("mobile@useinsider.com")?
.addPhoneNumber()("+901234567")?
.addUserID()("CRM-ID")
Insider.getCurrentUser().login(identifiers)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 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
-(InsiderIdentifiers *(^)(NSString *))addUserID;Method Examples
InsiderIdentifiers *insiderIdentifiers = [[InsiderIdentifiers alloc] init];
insiderIdentifiers.addEmail(@"mobile@useinsider.com")
.addPhoneNumber(@"+901234567")
.addUserID(@"CRM-ID");
[[Insider getCurrentUser] login:insiderIdentifiers];let identifiers = InsiderIdentifiers()
identifiers.addEmail()("mobile@useinsider.com")?
.addPhoneNumber()("+901234567")?
.addUserID()("CRM-ID")
Insider.getCurrentUser().login(identifiers)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 name attribute
This method allows you to set the name attribute for your Insider user object.
| Parameter | Data Type |
|---|---|
| name | String |
Method Signature
-(InsiderUser*(^)(NSString *))setName;Method Examples
[Insider getCurrentUser].setName(@"name");Insider.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
-(InsiderUser*(^)(NSString *))setSurname;Method Examples
[Insider getCurrentUser].setSurname(@"surname");Insider.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
-(InsiderUser*(^)(InsiderGender))setGender;Method Examples
[Insider getCurrentUser].setGender(InsiderGenderOther);Insider.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
-(InsiderUser*(^)(int))setAge;Method Examples
[Insider getCurrentUser].setAge(23);Insider.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
-(InsiderUser*(^)(NSDate *))setBirthday;Method Examples
[Insider getCurrentUser].setBirthday([NSDate date]);Insider.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
-(InsiderUser*(^)(NSString *))setLanguage;Method Examples
[Insider getCurrentUser].setLanguage(@"language");Insider.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.
| Parameter | Data Type |
|---|---|
| emailOptin | Boolean |
Method Signature
-(InsiderUser*(^)(bool))setEmailOptin;Method Examples
[Insider getCurrentUser].setEmailOptin(true);Insider.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
-(InsiderUser*(^)(bool))setSMSOptin;Method Examples
[Insider getCurrentUser].setSMSOptin(true);Insider.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
-(InsiderUser*(^)(bool))setWhatsappOptin;Method Examples
[Insider getCurrentUser].setWhatsappOptin(true);Insider.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
-(InsiderUser*(^)(bool))setPushOptin;Method Examples
[Insider getCurrentUser].setPushOptin(true);Insider.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
-(InsiderUser*(^)(bool))setLocationOptin;Method Examples
[Insider getCurrentUser].setLocationOptin(true);Insider.getCurrentUser()?.setLocationOptin()(true)Set login attribute
This method allows you to set the login status attribute for your Insider user object.
Method Signature
-(InsiderUser*(^)(void))login;Method Examples
InsiderIdentifiers *insiderIdentifiers = [[InsiderIdentifiers alloc] init];
insiderIdentifiers.addEmail(@"sample@mail.com")
.addUserID(@"CRM-ID")
.addPhoneNumber(@"+1234567");
[[Insider getCurrentUser] login:insiderIdentifiers]; Insider.getCurrentUser()?.login()Set logout attribute
This method allows you to set the login status attribute for your Insider user object.
Method Signature
-(void)logout;Method Examples
[[Insider getCurrentUser] logout];Insider.getCurrentUser()?.logout()Set logout-reset attribute
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.
Method Signature
-(void)logoutResettingInsiderID:(NSArray<InsiderIdentifiers *> *)additionalIdentifiersMethod Examples
// Logout the current user only
[Insider.getCurrentUser logoutResettingInsiderID:nil];
// Logout the current user along side additional users
InsiderIdentifiers *insiderIdentifiers = [[InsiderIdentifiers alloc] init];
insiderIdentifiers.addEmail(@"sample@mail.com")
.addPhoneNumber(@"+1234567890")
.addUserID(@"CRM-ID");
[Insider.getCurrentUser logoutResettingInsiderID:@[insiderIdentifiers]];// Logout the current user only
Insider.getCurrentUser().logoutResettingInsiderID(nil)
// Logout the current user along side additional users
let insiderIdentifiers = InsiderIdentifiers()
.addEmail()("sample@mail.com")
.addPhoneNumber()("+1234567890")
.addUserID()("CRM-ID")
Insider.getCurrentUser().logoutResettingInsiderID([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
+(void)signUpConfirmation;Method Example
[Insider signUpConfirmation];Insider.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
-(InsiderUser *(^)(NSString *))setLocale;Method Examples
[Insider getCurrentUser].setLocale(@"en_EN");Insider.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
-(InsiderUser*(^)(NSString *, NSString *))setCustomAttributeWithString;Method Examples
[Insider getCurrentUser].setCustomAttributeWithString(@"key", @"stringValue");Insider.getCurrentUser()?.setCustomAttributeWithString()("key", "value")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
-(InsiderUser*(^)(NSString *, int))setCustomAttributeWithInt;Method Examples
[Insider getCurrentUser].setCustomAttributeWithInt(@"key",10);Insider.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
-(InsiderUser*(^)(NSString *, BOOL))setCustomAttributeWithBoolean;Method Examples
[Insider getCurrentUser].setCustomAttributeWithBoolean(@"key", true);Insider.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
-(InsiderUser*(^)(NSString *, double))setCustomAttributeWithDouble;Method Examples
[Insider getCurrentUser].setCustomAttributeWithDouble(@"key", 10.5);Insider.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
-(InsiderUser*(^)(NSString *, NSDate *))setCustomAttributeWithDate;Method Examples
[Insider getCurrentUser].setCustomAttributeWithDate(@"key", [NSDate date]);Insider.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
-(InsiderUser*(^)(NSString *, NSArray *))setCustomAttributeWithArray;Method Examples
NSArray *arr = [NSArray arrayWithObjects: @"value1", @"value2", @"value3", nil];
[Insider getCurrentUser].setCustomAttributeWithArray(@"key", arr);let arr = ["value1", "value2", "value3"]
Insider.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 custom attribute of your user for the given key permanently.
| Parameter | Data Type |
|---|---|
| key | String |
Method Signature
-(InsiderUser*(^)(NSString *))unsetCustomAttribute;Method Examples
[Insider getCurrentUser].unsetCustomAttribute(@"key");Insider.getCurrentUser()?.unsetCustomAttribute()("key")For troubleshooting, refer to Why cannot we trigger the login method a second time in an active session, Confusion of attributes among users after login