java.lang.Object | |||||
↳ | java.util.AbstractMap<K, V> | ||||
↳ | com.google.api.client.util.GenericData | ||||
↳ | com.google.api.client.json.GenericJson | ||||
↳ | com.kinvey.java.User | ||||
↳ | com.kinvey.android.AsyncUser |
Wraps the com.kinvey.java.User public methods in asynchronous functionality using native Android AsyncTask.
This functionality can be accessed through the user()
convenience method.
Methods in this API use either KinveyUserCallback
for authentication, login, and
user creation, or the general-purpose KinveyClientCallback
used for User data retrieval,
updating, and management.
Login sample:
public void submit(View view) { kinveyClient.user().login(mEditUserName.getText().toString(), mEditPassword.getText().toString(), new KinveyUserCallback() { public void onFailure(Throwable t) { CharSequence text = "Wrong username or password."; Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show(); } public void onSuccess(User u) { CharSequence text = "Welcome back," + u.getUserName() + "."; Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show(); LoginActivity.this.startActivity(new Intent(LoginActivity.this, SessionsActivity.class)); LoginActivity.this.finish(); } }); }
Saving user data sample:
User user = kinveyClient.getActiveUser(); user.put("fav_food", "bacon"); user.update(new KinveyClientCallback() { public void onFailure(Throwable e) { ... } public void onSuccess(User u) { ... } });
This class is not thread-safe.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
create(String username, String password, KinveyUserCallback callback)
Asynchronous method to create a new Kinvey User.
| ||||||||||
void |
delete(Boolean hardDelete, KinveyUserDeleteCallback callback)
Asynchronous Call to Delete the current user from the Kinvey backend
Constructs an asynchronous request to delete the current Kinvey user. | ||||||||||
void |
login(KinveyUserCallback callback)
Asynchronous implicit user login.
| ||||||||||
void |
login(String userid, String password, KinveyUserCallback callback)
Asynchronous Kinvey user login.
| ||||||||||
void | loginAuthLink(String accessToken, String refreshToken, KinveyUserCallback callback) | ||||||||||
void |
loginFacebook(String accessToken, KinveyUserCallback callback)
Asynchronous Facebook login.
| ||||||||||
void |
loginGoogle(String accessToken, KinveyUserCallback callback)
Asynchronous Google login.
| ||||||||||
void |
loginLinkedIn(String accessToken, String accessSecret, String consumerKey, String consumerSecret, KinveyUserCallback callback)
Asynchronous Linked In login.
| ||||||||||
void |
loginTwitter(String accessToken, String accessSecret, String consumerKey, String consumerSecret, KinveyUserCallback callback)
Asynchronous Twitter login.
| ||||||||||
void |
registerPush(KinveyClientCallback<Void> callback)
Asynchronous call to register current user for push notifications
Constructs an Asynchronous request to register the current user for Push notifications. | ||||||||||
void |
registerPush()
Register current user for push notifications
The registerPush method registers the current user for Push notifications. | ||||||||||
void |
resetPassword(KinveyUserManagementCallback callback)
Asynchronous Call to initiate a Password Reset request
The reset password request initiates a server-side process to reset a user's password. | ||||||||||
<T> void |
retrieve(Query q, KinveyClientCallback<T> callback)
Asynchronous Call to Retrieve users via a Query
Constructs an asynchronous request to retrieve User objects via a Query. | ||||||||||
<T> void |
retrieve(KinveyClientCallback<T> callback)
Asynchronous Call to Retrieve (refresh) the current user
Constructs an asynchronous request to refresh current user's data via the Kinvey back-end. | ||||||||||
void |
sendEmailVerification(KinveyUserManagementCallback callback)
Asynchronous Call to initiate an Email Verification request
The email verification request initiates a server-side process to verify a user's email. | ||||||||||
void |
unregisterPush()
Asynchronous call to unregiseter current user for push notifications
Constructs an Asynchronous request to remove the registration for the current user from Push notifications. | ||||||||||
void |
unregisterPush(KinveyClientCallback<Void> callback)
Unregisters current user from receiving push notifications
The unregisterPush method removes the registration for the current user from Push notifications. | ||||||||||
<T> void |
update(KinveyUserCallback callback)
Asynchronous Call to Save the current user
Constructs an asynchronous request to save the current Kinvey user. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Asynchronous method to create a new Kinvey User.
Constructs an asynchronous request to create a Kinvey user with username and password, and returns the associated User object via a KinveyUserCallback. All metadata that is added to the user object prior to creating the user will be persisted to the Kinvey backend.
Sample Usage:
kinveyClient.user().put("State","MA"); kinveyClient.user().put("Age", 25); kinveyClient.user().create(mEditUserName.getText().toString(), mEditPassword.getText().toString(), new KinveyUserCallback() { public void onFailure(Throwable t) { CharSequence text = "Unable to create account."; Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show(); } public void onSuccess(User u) { CharSequence text = "Welcome " + u.getUserName() + "."; Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show(); } });
username | username of the Kinvey User |
---|---|
password | password of the Kinvey user |
callback | KinveyUserCallback containing a new User instance.
|
Asynchronous Call to Delete the current user from the Kinvey backend
Constructs an asynchronous request to delete the current Kinvey user. The hardDelete flag determines whether the user is simply marked as inactive or completely erased from the Kinvey backend.
Sample Usage:
User user = kinveyClient.getActiveUser(); user.delete(new KinveyUserDeleteCallback() {
hardDelete | Erases user from Kinvey backend if true; inactivates the user if false. |
---|---|
callback | KinveyUserDeleteCallback .
|
Asynchronous implicit user login.
Constructs an asynchronous request to log in an implicit (non-named) user and returns the associated User object via a KinveyUserCallback.
Sample Usage:
kinveyClient.user().login(new KinveyUserCallback() { public void onFailure(Throwable t) { ... } public void onSuccess(User u) { CharSequence text = "Welcome back!"; Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show(); } });
callback | KinveyUserCallback that returns a valid user object
|
---|
Asynchronous Kinvey user login.
Constructs an asynchronous request to log in a Kinvey user with username and password, and returns the associated User object via a KinveyUserCallback.
Sample Usage:
kinveyClient.user().login(mEditUserName.getText().toString(), mEditPassword.getText().toString(), new KinveyUserCallback() { public void onFailure(Throwable t) { CharSequence text = "Wrong username or password."; Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show(); } public void onSuccess(User u) { CharSequence text = "Welcome back," + u.getUserName() + "."; Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show(); LoginActivity.this.startActivity(new Intent(LoginActivity.this, SessionsActivity.class)); LoginActivity.this.finish(); } });
userid | userID of the Kinvey User |
---|---|
password | password of the Kinvey user |
callback | KinveyUserCallback that returns a valid user object
|
Asynchronous Facebook login.
Constructs an asynchronous request to log in a Facebook user and returns the associated User object via a KinveyUserCallback. A valid Facebook access token must be obtained via the Facebook OAuth API and passed to this method.
Sample Usage:
kinveyClient.user().loginFacebook(accessToken, new KinveyUserCallback() { public void onFailure(Throwable e) { error(progressDialog, "Kinvey: " + e.getMessage()); Log.e(TAG, "failed Kinvey facebook login", e); } public void onSuccess(User u) { Log.d(TAG, "successfully logged in with facebook"); } });
accessToken | Facebook-generated access token. |
---|---|
callback | KinveyUserCallback that returns a valid user object
|
Asynchronous Google login.
Constructs an asynchronous request to log in a Google user and returns the associated User object via a KinveyUserCallback. A valid Google access token must be obtained via the Google OAuth API and passed to this method.
Sample Usage:
kinveyClient.user().loginGoogle(accessToken, new KinveyUserCallback() { public void onFailure(Throwable e) { error(progressDialog, "Kinvey: " + e.getMessage()); Log.e(TAG, "failed Kinvey facebook login", e); } public void onSuccess(User u) { Log.d(TAG, "successfully logged in with facebook"); } });
accessToken | Google-generated access token. |
---|---|
callback | KinveyUserCallback that contains a valid logged in user
|
Asynchronous Linked In login.
Constructs an asynchronous request to log in a Linked In user and returns the associated User object via a KinveyUserCallback. A valid Linked In access token, access secret, consumer key, and consumer secret must be obtained via the Linked In OAuth API and passed to this method.
Sample Usage:
kinveyClient.user().loginLinkedIn(accessToken, accessSecret, LINKEDIN_CONSUMER_KEY, LINKEDIN_CONSUMER_SECRET, new KinveyUserCallback() { public void onFailure(Throwable e) { Log.e(TAG, "Failed Kinvey login", e) }; public void onSuccess(User r) { Log.e(TAG, "Successfully logged in via Linked In"); } });
accessToken | Linked In-generated access token |
---|---|
accessSecret | Linked In-generated access secret |
consumerKey | Linked In supplied developer consumer key |
consumerSecret | Linked In supplied developer consumer secret |
callback | KinveyUserCallback that returns a valid user object
|
Asynchronous Twitter login.
Constructs an asynchronous request to log in a Twitter user and returns the associated User object via a KinveyUserCallback. A valid Twitter access token, access secret, consumer key, and consumer secret must be obtained via the Twitter OAuth API and passed to this method.
Sample Usage:
kinveyClient.user().loginTwitter(accessToken, accessSecret, TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, new KinveyUserCallback() { public void onFailure(Throwable e) { Log.e(TAG, "Failed Kinvey login", e) }; public void onSuccess(User r) { Log.e(TAG, "Successfully logged in via Twitter"); } });
accessToken | Twitter-generated access token |
---|---|
accessSecret | Twitter-generated access secret |
consumerKey | Twitter supplied developer consumer key |
consumerSecret | Twitter supplied developer consumer secret |
callback | KinveyUserCallback that returns a valid user object
|
Asynchronous call to register current user for push notifications
Constructs an Asynchronous request to register the current user for Push notifications. Push must have already been activated for the current application and a logged-in user context must exist. This must be called when enabling push for a user on a device. Once called, it does not have to be called again unless push has been explicitly disabled for a user, the app has been uninstalled / reinstalled, or app data has been cleared.
Sample Usage:
kinveyClient.push().initialize(pushOptions,myApplication); kinveyClient.user().registerPush(new KinveyClientCallback{ onSuccess(Void v) { ... } onFailure(Throwable t) { ... } });
callback | KinveyClientCallback |
---|
Register current user for push notifications
The registerPush method registers the current user for Push notifications. Push must have already been activated for the current application and a logged-in user context must exist. This must be called when enabling push for a user on a device. Once called, it does not have to be called again unless push has been explicitly disabled for a user, the app has been uninstalled / reinstalled, or app data has been cleared.
Sample Usage:
kinveyClient.push().initialize(pushOptions,myApplication); kinveyClient.user().registerPush();
Asynchronous Call to initiate a Password Reset request
The reset password request initiates a server-side process to reset a user's password. Once executed, a success callback is initiated. The user is then emailed by the server to receive the password reset. The user's email address must be stored in a property named 'email' in the User collection.
Sample Usage:
kinveyClient.resetPassword(new KinveyClientCallback() {
callback | KinveyUserManagementCallback
|
---|
Asynchronous Call to Retrieve users via a Query
Constructs an asynchronous request to retrieve User objects via a Query.
Sample Usage:
User user = kinveyClient.user(); user.retrieve(Query query, new KinveyUserListCallback() {
callback | KinveyUserListCallback for retrieved users. |
---|
Asynchronous Call to Retrieve (refresh) the current user
Constructs an asynchronous request to refresh current user's data via the Kinvey back-end.
Sample Usage:
User user = kinveyClient.user(); user.retrieve(new KinveyUserCallback() {
callback | KinveyUserCallback containing a refreshed User instance. |
---|
Asynchronous Call to initiate an Email Verification request
The email verification request initiates a server-side process to verify a user's email. Once executed, a success callback is initiated. The user is then emailed by the server to receive the email verification. The user's email address must be stored in a property named 'email' in the User collection.
Sample Usage:
kinveyClient.sendEmailVerification(new KinveyClientCallback() {
callback | KinveyUserManagementCallback
|
---|
Asynchronous call to unregiseter current user for push notifications
Constructs an Asynchronous request to remove the registration for the current user from Push notifications. Push must have already been activated for the current application and a logged-in user context must exist. Once called, a user on a specific device will no longer receive push notifications for the app until explicitly reenabled.
Sample Usage:
kinveyClient.push().initialize(pushOptions,myApplication); kinveyClient.user().unregisterPush(new KinveyClientCallback{ onSuccess(Void v) { ... } onFailure(Throwable t) { ... } });
Unregisters current user from receiving push notifications
The unregisterPush method removes the registration for the current user from Push notifications. Push must have already been activated for the current application and a logged-in user context must exist. Once called, a user on a specific device will no longer receive push notifications for the app until explicitly reenabled.
Sample Usage:
kinveyClient.push().initialize(pushOptions,myApplication); kinveyClient.user().unregisterPush();
callback | KinveyClientCallback |
---|
Asynchronous Call to Save the current user
Constructs an asynchronous request to save the current Kinvey user.
Sample Usage:
User user = kinveyClient.user(); user.update(new KinveyUserCallback() {
callback | KinveyUserCallback containing an updated User instance. |
---|