User Reference


Extends: UserData
Package: com.applicasa.User
Declared In: com.applicasa.User.User

Overview


The User class is a default class provided by Applicasa to help developers easily add users and user-based functionality to their applications.

Users are an integral part of any successful application. Applicasa's User class provides a base object for creating, editing, and enhancing user accounts, as well as a number of other helpful methods and properties that are specific to the User class itself.

It is worth mentioning that, as with all Applicasa-provided default object classes, the User class fields can only be added to. Developers cannot remove default properties and fields from the class, but they can use the web console to add additional fields to the User class as their application requires.


Tasks


Creating and Editing Users

save(LiCallbackAction)
registerUser(String, String, LiCallbackUser)
uploadFile(LiFieldUser, String, LiCallbackAction)

Updating Credentials

updateUsername(String, String, LiCallbackUser)
updateUserPassword(String, String, LiCallbackUser)
forgotPassword(String, LiCallbackUser)

Applicasa Authentication

loginUser(String, String, LiCallbackUser)
logoutUser(LiCallbackUser)

Facebook Authentication

loginWithFacebookUser(Activity, String[], LiFacebookResponse)

Facebook Actions

getFacebookFriendsWithUser(Activity, LiFacebookResponse)
postOnUserWall(Activity, LiDialogListener)
postOnUserWall(Activity, Bundle, LiDialogListener)
postOnFriendsWallWithDialog(Activity, String, Bundle, LiDialogListener)
postOnFriendsWall(Activity, String, Bundle, LiDialogListener)

Retrieving Users

getCurrentUser
getByID(String, QueryKind, LiUserGetByIDCallback)
getArrayWithQuery(LiQuery, QueryKind, LiUserGetArrayCallback)
getArrayWithQuery(LiQuery, QueryKind)
getLocalArrayWithRawSQLQuery(String, String[], LiUserGetArrayCallback)


Properties


UserId

The item's unique ID value.

public String UserId;

Discussion:

This is a user's unique ID value as recorded in the Applicasa datastore. It is set by the datastore when you register a new user. You can use this for such tasks as, among other custom uses, querying users by their ID value to retrieve a specific object from the datastore.

UserName

A user's username.

public String UserName;

Discussion:

This is a user's username. It cannot be edited directly. This value is created and updated with the registerUser() and updateUsername() methods.

UserFirstName

A user's first name.

public String UserFirstName;

Discussion:

A user's first name. This field is editable.

UserLastName

A user's last name.

public String UserLastName;

Discussion:

A user's last name. This field is editable.

UserEmail

A user's email address.

public String UserEmail;

Discussion:

A user's email address. This field is editable.

UserPhone

A user's phone number.

public String UserPhone;

Discussion:

A user's phone number. This field is editable.

UserPassword

A user's password.

public String UserPassword;

Discussion:

A user's password. It cannot be edited directly. This value is created and updated with the registerUser() and updateUserPassword() methods.

UserLastLogin

The user's last login date.

public GregorianCalendar UserLastLogin;

Discussion:

The user's last login date. It cannot be edited directly, and is updated by Applicasa when the loginWithUsername:andPassword:withBlock: method is called.

UserRegisterDate

The user's registration date.

public GregorianCalendar UserRegisterDate;

Discussion:

The user's registration date. It cannot be edited directly, and is set by Applicasa when the registerUser() method is called.

UserLocation

The user's current location.

public LiLocation UserLocation;

Discussion:

The user's current location, updated whenever location-related methods from LiUserLocation are called.

UserIsRegistered

A boolean value that indicates whether the current user is anonymous or not.

public Boolean userIsRegistered;

Discussion:

A boolean value that indicates whether the current user is anonymous or not. This value is readonly, and defaults to false for new users. It is set to true when the registerUser() method is called.

UserIsRegisteredFacebook

A boolean value that indicates whether the current user is anonymous or not.

public Boolean userIsRegisteredFacebook;

Discussion:

A boolean value that indicates whether the current user has registered through Facebook. This value is readonly, and defaults to false for new users. It is set to true when a user registers via Facebook if your application is using Applicasa's Facebook Kit.

UserLastUpdate

A GregorianCalendar value of the last time the object was updated.

public GregorianCalendar UserLastUpdate;

Discussion:

The userLastUpdate value is calculated by the Applicasa SDK and datastore. It is advised that developers not alter this value directly.

UserImage

A user's image URL.

public String UserImage;

Discussion:

An String providing the location of the user's image file. This is provided as a default field for setting profile images in applications, if desired. It is a URL to the image, not the image itself.

UserMainCurrencyBalance

A user's current main currency balance within an application's virtual economy.

public int userMainCurrencyBalance;

Discussion:

A user's current main currency balance within an applications virtual economy. This is constantly updated whenever a user performs virtual store actions, such as In-App Purchases, buying VirtualGood items, etc.

UserSecondaryCurrencyBalance

A user's current secondary currency balance within an application's virtual economy.

public int userSecondaryCurrencyBalance;

Discussion:

A user's current secondary currency balance within an applications virtual economy. This is constantly updated whenever a user performs virtual store actions, such as In-App Purchases, buying VirtualGood items, etc.

UserFacebookID

A user's Facebook ID.

public String UserFacebookID;

Discussion:

A user's Facebook ID, saved when a user registers or logs in via Facebook if your application is using Applicasa's Facebook Kit.


Class Methods


getCurrentUser

Returns the current active user object.

public static User getCurrentUser()

Return Value:

A User object representing the currently active user.

loginUser(String, String, LiCallbackUser)

Authenticates a user and logs them in if successful.

public static void loginUser(String UserName, String UserPassword, LiCallbackUser liCallbackUser)

Parameters:

UserName
A String indicating the user's username.

UserPassword
A String indicating the user's password.

liCallbackUser
A callback method that allows a developer to respond to method completion.

Discussion:

Authenticates a user via Applicasa, logging them in if UserName and UserPassword are correct. A developer can then use the liCallbackUser parameter to respond to method completion if desired.

updateUsername(String, String, LiCallbackUser)

Updates an existing user's username.

public static void updateUserame(String newUserName, String UserPassword, LiCallbackUser liCallbackUser)

Parameters:

newUserName
A String indicating the user's new username.

UserPassword
A String indicating the user's current password, for verification.

liCallbackUser
A callback method that allows a developer to respond to method completion.

Discussion:

This method allows a developer to update an existing user's username, supplying their current password to verify their identity. The developer provides a callback method to handle method completion.

updateUserPassword(String, String, LiCallbackUser)

Updates an existing user's password.

public static void updateUserPassword(String UserPassword, String newUserPassword, LiCallbackUser liCallbackUser)

Parameters:

UserPassword
A String indicating the user's current password, for verification.

newUserPassword
A String indicating the user's new password.

liCallbackUser
A callback method that allows a developer to respond to method completion.

Discussion:

This method allows a developer to update an existing user's password, supplying their current password to verify their identity. The developer provides a callback method to handle method completion.

logoutUser(LiCallbackUser)

Logs a user out of your application.

public static void logoutUser( LiCallbackUser liCallbackUser)

Parameters:

liCallbackUser
A callback method that allows a developer to respond to method completion.

Discussion:

Logout a user out of your application. A developer can then use the liCallbackUser parameter to respond to method completion if desired.

forgotPassword(String, LiCallbackUser)

Handles situations where users have forgotten their password.

public static void forgotPassword(String username, LiCallbackUser liCallbackUser)

Parameters:

foo
A callback method that allows a developer to respond to method completion.

Discussion:

Handles situations where users have forgotten their password by sending them an email with a new password. Requires that a developer has requested an email address from the user to succeed. A developer uses the liCallbackUser parameter to respond to method completion.

getByID(String, QueryKind, LiUserGetByIDCallback)

Class method for retrieving a User object by ID value.

public static void getByID(String Id, QueryKind queryKind, LiUserGetByIDCallback liUserGetByIDCallback)

Parameters:

Id
A String value representing the ID value of the object you wish to retrieve.

queryKind
A QueryKind constant indicating which type of query you wish to perform. Options are FULL, LIGHT, and LOCAL.

liUserGetByIDCallback
A callback method that allows a developer to respond to method completion and process results.

Discussion:

This method allows a developer to retrieve an object from the Applicasa datastore, indicate what kind of query the developer wishes to perform, and a callback method to execute on completion.

Applicasa provides a great deal of power to your queries via the queryKind parameter. This allows you to specify whether you want to perform a network query that looks up all related objects for their most recent values (FULL); a network query that only retrieves deltas of the most recent data for the given object itself, without looking up related objects (LIGHT); or a local-only query that hits the offline sqlite datastore Applicasa creates to ensure your application keeps working even when a network connection does not exist (LOCAL).

getArrayWithQuery(LiQuery, QueryKind, LiUserGetArrayCallback)

Asynchronous method for retrieving an object with a custom query and callback.

public static void getArrayWithQuery(LiQuery query, QueryKind queryKind, LiUserGetArrayCallback liUserGetArrayCallback)

Parameters:

query
An LiQuery instance representing the query for the objects you wish to retrieve.

queryKind
A QueryKind constant indicating which type of query you wish to perform. Options are FULL, LIGHT, and LOCAL.

liUserGetArrayCallback
An LiUserGetArrayCallback callback interface implementation that allows a developer to respond to method completion.

Discussion:

This method allows a developer to asynchronously retrieve User objects from the Applicasa datastore, indicate what kind of query the developer wishes to perform, and a callback method to process results.

Applicasa provides a great deal of power to your queries via the queryKind parameter. This allows you to specify whether you want to perform a network query that looks up all related objects for their most recent values (FULL); a network query that only retrieves deltas of the most recent data for the given object itself, without looking up related objects (LIGHT); or a local-only query that hits the offline sqlite datastore Applicasa creates to ensure your application keeps working even when a network connection does not exist (LOCAL).

getArrayWithQuery(LiQuery, QueryKind)

Blocking/synchronous method for retrieving an object with a custom query.

public static List getArrayWithQuery(LiQuery query, QueryKind queryKind)

Parameters:

query
An LiQuery instance representing the query for the objects you wish to retrieve.

queryKind
A QueryKind constant indicating which type of query you wish to perform. Options are FULL, LIGHT, and LOCAL.

Return Value:

A List of User items that match the provided query.

Discussion:

This method allows a developer to retrieve User objects from the Applicasa datastore in a synchronous or blocking manner, indicating what kind of query the developer wishes to perform. Because it is not asynchronous, it throws an instance of LiErrorHandler for responding to errors. LiErrorHandler extends the Exception class.

Applicasa provides a great deal of power to your queries via the queryKind parameter. This allows you to specify whether you want to perform a network query that looks up all related objects for their most recent values (FULL); a network query that only retrieves deltas of the most recent data for the given object itself, without looking up related objects (LIGHT); or a local-only query that hits the offline sqlite datastore Applicasa creates to ensure your application keeps working even when a network connection does not exist (LOCAL).

getLocalArrayWithRawSQLQuery(String, String[], LiUserGetArrayCallback)

Class method for retrieving an object locally (only) with a raw SQL WHERE statement.

public static void getLocalArrayWithRawSQLQuery(String whereClause, String[] args, LiUserGetArrayCallback liUserGetArrayCallback)

Parameters:

whereClause
An SQL WHERE clause representing the objects you wish to retrieve.

args
An array of arguments to insert into the whereClause.

liUserGetArrayCallback
A callback method that allows a developer to respond to method completion.

Discussion:

This method allows a developer to retrieve an object from the local Applicasa datastore via a raw SQL WHERE clause, and a callback method.

loginWithFacebookUser(Activity, String[], LiFacebookResponse)

Login user via Facebook.

public static void loginWithFacebookUser(Activity activity, String[] permission, LiFacebookResponse liFacebookResponse)

Parameters:

activity
The Activity object presented to the user.

permission
The Facebook permissions you wish to request on the user's behalf (e.g., publish_stream)

liFacebookResponse
The callback method to execute after method completion.

Discussion:

Logs a user into your application via Facebook, requiring permissions array and a callback to execute after method completion.

getFacebookFriendsWithUser(Activity, LiFacebookResponse)

Returns a user's Facebook friends list.

public static void GetFacebookFriendsWithUser(Activity activity, LiFacebookResponse liFacebookResponse)

Parameters:

activity
The Activity object presented to the user.

liFacebookResponse
Applicasa-provided custom interface for handling Facebook responses.

Discussion:

Finds a user's Facebook friends, requiring a callback for additional processing or action after friends are found.

postOnUserWall(Activity, LiDialogListener)

Posts a message to a Facebook user's wall via a dialog action.

public static void PostOnUserWall(Activity activity, LiDialogListener lidialogListener)

Parameters:

activity
The Activity object presented to the user.

lidialogListener
Callback interface for dialog requests. Applicasa-provided clone of Facebook.DialogListener.

Discussion:

Posts a message to a user's Facebook wall, with a LiDialogListener callback interface for dialog requests.

postOnUserWall(Activity, Bundle, LiDialogListener)

Posts a message to a Facebook user's wall with a Bundle that defines what message is to be posted.

public static void PostOnUserWall(Activity activity, Bundle params, LiDialogListener lidialogListener)

Parameters:

activity
The Activity object presented to the user.

params
A Bundle object that defines what message is to be posted.

lidialogListener
Callback interface for dialog requests. Applicasa-provided clone of Facebook.DialogListener.

Discussion:

Posts a message directly to a user's Facebook wall, with a LiDialogListener callback interface for dialog requests. The params argument is a Bundle object that accepts a key-value list of what data is to be posted.

postOnFriendsWallWithDialog(Activity, String, Bundle, LiDialogListener)

Posts a message to a Facebook user's friend's wall via a dialog action.

public static void PostOnFriendsWallWithDialog(Activity activity, String fbUserID, Bundle parameters, LiDialogListener lidialogListener )

Parameters:

activity
The Activity object presented to the user.

fbUserID
The Facebook ID of the friend to whose wall a message will be posted.

parameters
A Bundle object that defines what message is to be posted.

lidialogListener
Callback interface for dialog requests. Applicasa-provided clone of Facebook.DialogListener.

Discussion:

Posts a message to a Facebook user's friend's wall, opening a dialog in which you can confirm the message and what data is to be posted on the user's behalf. The parameters argument is a Bundle object that accepts a key-value list of data items to be posted.

postOnFriendsWall(Activity, String, Bundle, LiDialogListener)

Posts a message to a Facebook user's friend's wall.

public static void PostOnFriendsWall(Activity activity, String fbUserID, Bundle params, LiDialogListener lidialogListener )

Parameters:

activity
The Activity object presented to the user.

fbUserID
The Facebook ID of the friend to whose wall a message will be posted.

params
A Bundle object that defines what message is to be posted.

lidialogListener
Callback interface for dialog requests. Applicasa-provided clone of Facebook.DialogListener.

Discussion:

Posts a message directly to a Facebook user's friend's wall, optionally opening a dialog in which you can confirm the message and what data is to be posted on the user's behalf. The params argument is a Bundle object that accepts a key-value list of data items to be posted.


Instance Methods


save(LiCallbackAction)

Instance method for saving an existing User instance.

public void save(LiCallbackAction liCallbackAction)

Parameters:

liCallbackAction
A callback method that allows a developer to respond to method completion.

Discussion:

Saves existing User objects and allows a developer to respond to method completion with the liCallbackAction parameter.

NOTE: Creating new users requires using the registerUser() method.

registerUser(String, String, LiCallbackUser)

Registers a new user to your Applicasa datastore.

public void registerUser(String username, String password, LiCallbackUser liCallbackUser)

Parameters:

username
A String indicating the new user's username.

password
A String indicating the new user's password.

liCallbackUser
A callback method that allows a developer to respond to method completion.

Discussion:

This is the method to use when registering new users for an Applicasa-backed application. When a user launches the app, Applicasa's framework creates an anonymous User instance for developers. It is then up to you to prompt anonymous users for a username and password to successfully register them. Once registered, you can prompt for additonal information, update the User instance, and then use save() to update the User to the datastore.

uploadFile(LiFieldUser, String, LiCallbackAction)

Instance method for uploading a file to a given object field.

public void updloadFile(LiFieldUser liFieldUser, String filePath, LiCallbackAction liCallbackAction)

Parameters:

liFieldUser
The field to which you wish to upload the file.

filePath
The location of the file you wish to upload.

liCallbackAction
A callback method that allows a developer to respond to method completion.

Discussion:

This method enables a developer to upload a file to an object field via the Applicasa SDK. It uploads the file to Amazon S3, and provides a callback method that allows you to respond to method completion.


  « Back to SDK Class List