API Reference
Log In
  • The app User object manages information about current application user.

  • This object is optional, and it is used when the app needs to authenticate the user.

  • The authentication provides data about user’s identity: a unique user ID or similar.

  • The user login and logout calls are managed by the app.

  • To access existing User object, use currentUser property:

//If no login has been done
MOCAUser user = MOCA.getInstance().login(applicationUserId);

//User is already logged in
MOCAUser user = MOCA.getInstance().getUser();

🚧

User will persist across restarts

User will stay "Logged in" in MOCA SDK until you explicitly call the logout method

  • To logout a user, call:
user.logout()
  • The user object holds a collection of properties. Property-value pairs can be set and retrieved.
  • Each user object is persisted both locally and in the cloud.
  • It is recommended to perform as many sets as desired and then
    just invoke a single save operation to persist them to the MOCA cloud.
user.setProperty("is_tester", true);
user.setProperty("gender", "male");
user.setProperty("height", 175.2);
user.setProperty("dateOfBirth", 0);
user.save(new MOCACallback<MOCAUser>() {
  @Override
  public void success(MOCAUser user) {

  }

  @Override
  public void failure(MOCAException error) {

  }
});