Cordova iOS User profile

Attention! The support of the SDK for this platform has been suspended!


Additionally to basic methods, you can observe and change the user profiles data. User profile is the set or properties describing the user. User properties can be divided into 4 groups:

  1. Crossplatform or custom user identifier. If this identifier is not set by 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. Default set of user properties, which can be set by developer. The set of this parameters works with separate methods. This set includes the data of user's name, sex, age, e-mail, phone-number and url of user picture. Also this set includes the mark of user as cheater.
  4. Custom set of user properties. In this case 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.

 

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 which are the parts of cross-platform project. You also can use this identifier in non-crossplatform projects, but in your app the own unique user identifier is used.

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 setCrossplatformUserId method call.

If your cross-platform application supposes to be used without cross-platform authorization, don't use the setCrossplatformUserId 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 assigns to the user.

/**
* Initializes the user with the specified cross-platform identifier
* @param {string} сrossplatformUserId - unique cross-platform user ID used
* for user identification on your server.
*/

plugins.devtodev.setUserId(userId);

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

​To see which identifier is used at the moment:

/**
* Returns current cross-platform user id
* @return crossPlatformUserId - current cross-platform user id
*/

plugins.devtodev.getUserId();

 

Replace Cross-platform user ID

If it is possible to replace the cross-platform user identifier in your application (say, to make changes in the login/user id for particular user), use this method at the moment of replacing the identifier.
Attention! Don't use this method if you're going to perform the user's relogin!

/**
* Replaces current cross-platform user id
* Attention! Don't use this method if you're going to perform the user's relogin.
* @param {string} newCrossPlatformID - new cross-platform user ID
*/

plugins.devtodev.replaceUserId(oldUserId, newUserId);

 

Current user level

If your app uses the user's level mark, we recommend to use this method after every SDK initialization, as soon as data of user's level is available to the application. 

/**
* Initializes the current user level. Required if level feature used in the app.
* @param {number} currentUserLevel - Сurrent game level of the player.
*/

plugins.devtodev.setCurrentLevel(currentUserLevel);

 

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 {boolean} isCheater - true if user is a cheater
*/

plugins.devtodev.user.cheater(isCheater);

 

Name

User's name. Default user profile property.

/**
* Track user's name
* @param {string} name - User’s name.
*/
plugins.devtodev.user.name(name);

 

Age

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

/**
* Track user's age
* @param {number} age - User’s age.
*/

plugins.devtodev.user.age(age);

 

Gender

User's gender. Default user profile property.

/**
* Track user's gender
* @param {number} gender - User’s gender. (0 - Unknown, 1 - Male, 2 - Female).
*/

plugins.devtodev.user.gender(gender);

 

E-mail

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

/**
* Track user's e-mail
* @param {string} email - User’s e-mail.
*/
plugins.devtodev.user.email(email);

 

Phone number

User's phone. Default user profile property.

/**
* Track user's phone number
* @param {string} phone_number - User’s phone number.
*/

plugins.devtodev.user.phone(phone_number);

Photo

User's photo URL. Default user profile property.

/**
* Track user's photo URL
* @param {string} photo_url - User’s phone number.
*/

plugins.devtodev.user.photo(photo_url);

Custom user property

Set properties on the current user profile.

/*
 * Set properties on a user data.
 *
 * ### Usage:
 *     plugins.devtodev.user.set('Hair color', 'copper red');
 *
 *     // to set multiple properties at once
 *     plugins.devtodev.user.set({
 *         'Hair color': 'blonde',
 *			'Last payment': 100,
 *			'Last order': ['Coloring','Hair Straightening'],
 *         'Order date': new Date()
 *     });
 *     // properties can be strings, integers, dates, or lists
 *
 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
 * @param {*} [val] A value to set on the given property
 */
plugins.devtodev.user.set(prop);
plugins.devtodev.user.set(prop, val);  //if prop is a string

Increment of the custom property

Increments the given numeric properties by the given values.

/*
 * Increments or decrements numeric user's properties.
 * ### Usage:
 *     plugins.devtodev.user.increment('Rounds played', 1);
 *     // or if you're just incrementing a counter by 1, you can simply do
 *     plugins.devtodev.user.increment('Rounds played');
 *
 *     // to decrement a counter, pass a negative number
 *     plugins.devtodev.user.increment('Rounds played', -1);
 *
 *     // you can increment multiple properties at once:
 *     plugins.devtodev.user.increment({
 *         'Rounds played': 1,
 *         'Enemies killed': 6
 *     });
 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and numeric values.
 * @param {Number} [val] An amount to increment the given property
 */
plugins.devtodev.user.increment(prop); 
plugins.devtodev.user.increment(prop, val); // If prop is a string.

 

Append to custom property

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.

/**
 * Multiple append list-valued properties at once
 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
 * @param {*} [val] A value to set on the given property
 */
plugins.devtodev.user.append(prop);
plugins.devtodev.user.append(prop, val); //if prop is a string

 

Union with custom property

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.

/**
 * Multiple union of a given lists with a list-valued properties at once
 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
 * @param {*} [val] A value to set on the given property
 */
plugins.devtodev.user.union(prop);
plugins.devtodev.user.union(prop, val); //if prop is a string

 

Removing of the custom property

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

/*
 * Removes properties from a user data.
 *
 * ### Usage:
 *     plugins.devtodev.user.unset('Hair color');
 *
 *     // to set multiple properties at once
 *     plugins.devtodev.user.unset(['Hair color', 'blonde', 'Last payment']);
 *
 * @param {Array|String} prop If a string, this is the name of the property. If an array, this is an array of names.
 */
plugins.devtodev.user.unset(prop);

 

Clearing of the all custom user properties

/*
 * Removes all user's custom personal data from devtodev data base.
 */

devtodev.user.clear();

 

Basic Methods
Secondary Methods