User profile

In addition to basic methods, you can observe and change the user profiles data. A user profile is the set of properties describing the user, which can be divided into 4 groups:

  1. Cross-platform or custom user identifier. If this identifier is not set by a developer, then the device identifier is used.

  2. Automatically collected properties, including data about user's device, geography, app version, SDK, and some other data which can be received from SDK.

  3. The default set of user properties, which can be set by a developer. The set of this parameters works with separate methods. This set includes the data of the user's name, sex, age, e-mail, phone number and URL of user picture. Also, this set includes the mark of a user as a cheater.

  4. Custom set of user properties. In this case, a developer sets any user data he/she needs to know. The data is set in key-value format and can be numeric, string, array, or boolean. Each project can have up to 30 custom user properties.

You can segment users by all the properties in My Apps section of an application.

Cross-platform user ID

This method is used for user initialization in the applications that are the parts of cross-platform project.

We recommend you to apply this method before the SDK initialization, otherwise the user identifier from the previous session will be used since the SDK initialization moment till the setUserID method call.

If your cross-platform application is supposed to be used without cross-platform authorization, don't use the setUserID method or use the empty string ("") as the user identifier. SDK will assign the unique identifier to user. This identifier will be used until the real cross-platform identifier is assigned to the user.

If your application allows user to re-login (changing the user during the working session of the application), then the setUserID method should be called just after the authorization. You don't need to call the SDK initialization one more time.

/**
* Initializes the user with the specified cross-platform identifier
* @param NSString userId - unique cross-platform user ID used
* for user identification on your server.
*/
[DevToDev setUserId: (NSString *) userId];

To see which identifier is used at the moment:

/**
* Returns current cross-platform user id
* @return userId - current cross-platform user id
*/
[DevToDev getUserId];

Replace Cross-platform user ID

If it is possible to replace the user identifier in your application (for example, to make changes in the login/user id for a particular user), use this method at the moment of replacing the identifier.

Don't use this method if you're going to perform the user's re-login.

/**
* Replaces current cross-platform user id
* Attention! Don't use this method if you're going to perform the user's relogin.
* @param NSString prevUserId - previous cross-platform user ID
* @param NSString userId - new cross-platform user ID
*/
[DevToDev replaceUserId: (NSString *) prevUserId to: (NSString *) userId];

Current user level

This method is used in cross-platform applications and applications with data synchronization.

This method is required for user's level data initialization. We recommend you to use the setCurrentLevel method just after the user initialization (using the setUserID method).

Don't use the setCurrentLevel method at the moment of user's level up. We recommend you to use the levelUp method in this case.

/**
* Initializes the current user level. Required if level feature used in the app.
* @param NSUInteger level - current game level of the player.
*/
[DevToDev setCurrentLevel: (NSUInteger) level];

Cheater

In case you have your own methods of determining cheaters in the application, you can have such users marked. Payments made by them will not be taken into account in the statistics.

/**
* Mark user if it's cheater.
* @param BOOL isCheater - true if user is a cheater
*/
DevToDev.activeUser.cheater = isCheater;

Name

User's name. Default user profile property.

We strongly recommend not to use this property because it refers to personal data.

/**
* Track user's name
* @param NSString name - User's name.
*/
DevToDev.activeUser.name = name;

Age

User's age in years. Default user profile property.

We strongly recommend not to use this property because it refers to personal data.

/**
* Track user's age
* @param NSNumber age - User's age
*/
DevToDev.activeUser.age = age;

Gender

User's gender. Default user profile property.

We strongly recommend not to use this property because it refers to personal data.

/**
* Track user's
* @param DTDGender gender - User's gender. (Unknown, Male, Female).
*/
DevToDev.activeUser.gender = gender;

E-mail

User's e-mail. Default user profile property.

We strongly recommend not to use this property because it refers to personal data.

/**
* Track user's e-mail
* @param NSString email - User's e-mail.
*/
DevToDev.activeUser.email = email;

Phone number

User's phone. Default user profile property.

We strongly recommend not to use this property because it refers to personal data.

/**
* Track user's phone number
* @param NSString phoneNumber - User's phone number.
*/
DevToDev.activeUser.phone = phoneNumber;

Photo

User's photo URL. Default user profile property.

We strongly recommend not to use this property because it refers to personal data.

/**
* Track user's photo URL
* @param NSString photoUrl - User's photo URL.
*/
DevToDev.activeUser.photo = photoUrl;

Custom user property

Each project in devtodev can have up to 30 custom user properties.Here is how you can set properties on the current user profile:

Attention! We strongly recommend that you do not use these properties to transfer and store data that fits the definition of personal data!

/**
 * Set properties on a user data.
 *
 * ### Usage:
 *     [DevToDev.activeUser setUserDataWithKey:@"Hair color" andValue: @"copper red"];
 *  properties can have string, integer, date or list type
 *
 * @param NSString key - the name of the property
 * @param {*} value -  a value to set on the given property
 */
[DevToDev.activeUser setUserDataWithKey: (NSString *) key andValue: (id) value];

/**
 * Set multiple properties at once
 *
 * ### Usage:
 *     [DevToDev.activeUser setUserData:@{
 *         @"Hair color"   : @"blonde",
 *           @"Last payment" : 100,
 *           @"Last order"   : @[ 
 *             @"Coloring",
 *             @"Hair Straightening"
 *         ],
 *         @"Order date"   : [NSDate date]
 *     }];
 *  properties can have string, integer, date or list type
 *
 * @param NSDictionary userData - an associative array of names and values.
 */
[DevToDev.activeUser setUserData: (NSDictionary *) userData];

Increment of the custom property

Increments the given numeric properties by the given values.

/**
 * Increments or decrements numeric user's properties.
 * ### Usage:
 *     [DevToDev.activeUser incrementWithKey: @"Rounds played" andValue: 1];
 *
 *     // to decrement a counter, pass a negative number
 *     [DevToDev.activeUser incrementWithKey: @"Rounds played" andValue: -1];
 *
 * @param NSString key - the name of the property
 * @param NSNumber value - an amount to increment the given property
 */
[DevToDev.activeUser incrementWithKey: (NSString *) key andValue: (id) value];

/**
 * Increments or decrements multiple numeric user's properties at once.
 *  ### Usage:
 *     [DevToDev.activeUser increment: @{
 *         @"Rounds played"  : 1,
 *         @"Enemies killed" : 6
 *     }];
 *
 * @param NSDictionary values - an associative array of property names and numeric values.
 */
[DevToDev.activeUser increment: (NSDictionary *) values];

Append to custom property (deprecated)

Adds values to a list-valued property. If the property does not currently exist, it will be created with the given list as it's value. If the property exists and is not list-valued, the append will be ignored.

/**
* Append values to list properties.
* @param NSString key - property name
* @param {NSString|NSNumber|NSNull|NSDictionary|NSDate|NSURL} value - appending value
*/
[DevToDev.activeUser appendWithKey: (NSString *) key andValue: (id) value];

/**
 * Multiple append list-valued properties at once
 * @param NSDictionary values - an associative array of property names and values.
 */
[DevToDev.activeUser append: (NSDictionary *) values];

Union with custom property (deprecated)

Adds values to a list-valued property only if they are not already present in the list. If the property does not currently exist, it will be created with the given list as it's value. If the property exists and is not list-valued, the union will be ignored.

/**
* Union a given list with a list-valued property, excluding duplicate values.
* @param NSString key - property name
* @param {NSString|NSNumber|NSNull|NSDictionary|NSDate|NSURL} value - appending value
*/
[DevToDev.activeUser unionWithKey: (NSString *) key andValue: (id) value];

/**
 * Multiple union of a given lists with a list-valued properties at once
 * @param NSDictionary values - an associative array of property names and values.
 */
[DevToDev.activeUser unionWithData: (NSDictionary *) values];

Removing of the custom property

Removes a property or a list of properties and their values from the current user's profile.

/**
 * Removes property from user data.
 *
 * ### Usage:
 *     [DevToDev.activeUser unsetUserDataWithKey: @"Hair color"];
 *
 * @param NSString key - the name of the property
 */
[DevToDev.activeUser unsetUserDataWithKey: (NSString *) key];

/**
 * Removes multiple properties from user data at once.
 *
 * ### Usage:
 *     [DevToDev.activeUser unsetUserData: @[ @"Hair color", @"blonde", @"Last payment" ]];
 *
 * @param NSArray keys - an array of property names.
 */
[DevToDev.activeUser unsetUserData: (NSArray *) keys];

Clearing of the all custom properties

/**
 * Removes all user's custom personal data from devtodev data base.
 */
[DevToDev.activeUser clearUserData];

Last updated