|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.stackmob.sdk.model.StackMobModel
com.stackmob.sdk.model.StackMobUser
public abstract class StackMobUser
A specialized subclass of StackMobModel to represent users of your app. Extend this class with the fields you want and you have an object that knows how to do logins as well as synchronize itself with the cloud.
public class User extends StackMobUser {
private String email;
private List<User> friends;
private List<TaskList> taskLists;
public User(String username, String password, String email) {
super(User.class, username, password);
this.email = email;
}
//Add whatever setters/getters/other functionality you want here
}
There is a built in concept of username and password, so you shouldn't declare fields for those. You must follow the same rules for fields as you would for StackMobModel.
Most likely your app will begin like this
if(stackmob.isLoggedIn()) {
User.getLoggedInUser(User.class, new StackMobQueryCallback<User>() {
public void success(List<User> result) {
startAppWithUserData(result.get(0));
}
public void failure(StackMobException e) {
// handle failure
}
});
} else {
// show login screen to get credentials
final User theUser = new User(username, password);
theUser.login(new StackMobModelCallback() {
public void success() {
startAppWithUserData(theUser);
}
public void failure(StackMobException e) {
// handle failure case
}
});
}
After either path you've got a confirmed logged in user and their user data.
| Field Summary |
|---|
| Fields inherited from class com.stackmob.sdk.model.StackMobModel |
|---|
id |
| Constructor Summary | |
|---|---|
protected |
StackMobUser(Class<? extends StackMobUser> actualClass)
Create a new user of the specified class. |
protected |
StackMobUser(Class<? extends StackMobUser> actualClass,
String username)
Create a new user of the specified class with a username. |
protected |
StackMobUser(Class<? extends StackMobUser> actualClass,
String username,
String password)
Create a new user of the specified class with a username and password. |
| Method Summary | ||
|---|---|---|
void |
createWithFacebook(String facebookToken,
StackMobCallback callback)
Create this user on StackMob and associate it with an existing Facebook user via Facebook credentials. |
|
void |
createWithTwitter(String twitterToken,
String twitterSecret,
StackMobCallback callback)
Create this user on StackMob and associate it with an existing Twitter user via Twitter credentials. |
|
void |
getFacebookUserInfo(StackMobRawCallback callback)
Get Facebook user info for the current user. |
|
String |
getIDFieldName()
Determines the field name for the primary key on the server. |
|
static
|
getLoggedInUser(Class<T> classOfT,
StackMobOptions options,
StackMobQueryCallback<T> callback)
Get the currently logged in user. |
|
static
|
getLoggedInUser(Class<T> classOfT,
StackMobQueryCallback<T> callback)
Get the currently logged in user. |
|
static String |
getLoggedInUsername()
Deprecated. |
|
void |
getPushTokens(StackMobRawCallback callback)
Retrieve the push tokens associated with this user. |
|
String |
getSchemaName()
The name of the schema this object corresponds to on the server. |
|
void |
getTwitterUserInfo(StackMobRawCallback callback)
Get Twitter user info for the current user. |
|
String |
getUsername()
Get the username, which also serves as a primary key. |
|
boolean |
isLoggedIn()
Check if the user is logged in. |
|
void |
linkWithFacebook(String facebookToken,
StackMobCallback callback)
Link a user with an existing Facebook user via Facebook credentials. |
|
void |
linkWithTwitter(String twitterToken,
String twitterSecret,
StackMobCallback callback)
Link a user with an existing Facebook user via Facebook credentials. |
|
protected void |
login(Map<String,String> args,
StackMobOptions options,
StackMobCallback callback)
Log this user into StackMob with specialized info. |
|
void |
login(StackMobCallback callback)
Log this user into StackMob. |
|
void |
login(StackMobOptions options,
StackMobCallback callback)
Log this user into StackMob. |
|
void |
loginResettingTemporaryPassword(String newPassword,
StackMobCallback callback)
Log this user into StackMob with their temporary password and reset their password. |
|
void |
loginResettingTemporaryPassword(String newPassword,
StackMobOptions options,
StackMobCallback callback)
Log this user into StackMob with their temporary password and reset their password. |
|
void |
loginWithFacebook(String facebookToken,
boolean createUser,
String username,
StackMobOptions options,
StackMobCallback callback)
Login to StackMob with Facebook credentials. |
|
void |
loginWithFacebook(String facebookToken,
StackMobCallback callback)
Login to StackMob with Facebook credentials. |
|
void |
loginWithGigya(String gigyaUid,
String timestamp,
String sig,
StackMobOptions options,
StackMobCallback callback)
Login to StackMob with gigya credentials. |
|
void |
loginWithTwitter(String twitterToken,
String twitterSecret,
boolean createUser,
String username,
StackMobOptions options,
StackMobCallback callback)
Login to StackMob with twitter credentials. |
|
void |
loginWithTwitter(String twitterToken,
String twitterSecret,
StackMobCallback callback)
Login to StackMob with twitter credentials. |
|
void |
logout(StackMobCallback callback)
Log the user out, clearing all credential. |
|
void |
postFacebookMessage(String msg,
StackMobRawCallback callback)
Post a message to Facebook. |
|
void |
postTwitterUpdate(String message,
StackMobRawCallback callback)
Update the logged in user’s Twitter status. |
|
static
|
pushToMultiple(Map<String,String> payload,
List<T> users,
StackMobRawCallback callback)
Send a push notification to a group of users. |
|
void |
refreshLogin(StackMobCallback callback)
Refresh the current OAuth2 login. |
|
boolean |
refreshRequired()
Check whether a refreshLogin(com.stackmob.sdk.callback.StackMobCallback) call is required
to continue making authenticated requests. |
|
void |
registerForPush(StackMobPushToken token,
StackMobRawCallback callback)
Register this user for push. |
|
void |
removeFromPush(StackMobPushToken token,
StackMobRawCallback callback)
Remove this token from push. |
|
void |
resetPassword(String oldPassword,
String newPassword,
StackMobCallback callback)
Reset this user's passwords. |
|
void |
save(StackMobOptions options,
StackMobCallback callback)
Save the object to the server with options. |
|
void |
sendPush(Map<String,String> payload,
StackMobRawCallback callback)
Send a push message to this user. |
|
static void |
sentForgotPasswordEmail(String username,
StackMobCallback callback)
Send out a password reset email to a user who's forgotten their password. |
|
void |
unlinkFromFacebook(StackMobCallback callback)
Unlink a user from their Facebook credentials, if linked. |
|
void |
unlinkFromTwitter(StackMobCallback callback)
Unlink a user from their Twitter credentials, if linked. |
|
| Methods inherited from class com.stackmob.sdk.model.StackMobModel |
|---|
append, appendAndSave, count, count, destroy, destroy, exists, fetch, fetch, fillFromJson, getID, hasData, init, newFromJson, query, query, query, query, remove, removeAndDelete, save, save, save, saveMultiple, saveMultiple, setID, setStackMob, toJson, toJson, toJsonElement |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected StackMobUser(Class<? extends StackMobUser> actualClass,
String username,
String password)
actualClass - The subclass being constructedusername - The user's usernamepassword - The user's password
protected StackMobUser(Class<? extends StackMobUser> actualClass,
String username)
actualClass - The subclass being constructedusername - The user's usernameprotected StackMobUser(Class<? extends StackMobUser> actualClass)
actualClass - The subclass being constructed| Method Detail |
|---|
public void save(StackMobOptions options,
StackMobCallback callback)
StackMobModelStackMobOptions#depthOf(int) to also save its children to the given depth.
save in class StackMobModeloptions - options, such and select and expand, to apply to the requestcallback - invoked when the save is complete
public static void sentForgotPasswordEmail(String username,
StackMobCallback callback)
username - The user who's forgotten their passwordcallback - Callback to be called when the server returns. may execute in a separate thread
public static <T extends StackMobUser> void pushToMultiple(Map<String,String> payload,
List<T> users,
StackMobRawCallback callback)
payload - The payload to sendcallback - Callback to be called when the server returns. may execute in a separate thread
public static <T extends StackMobUser> void getLoggedInUser(Class<T> classOfT,
StackMobQueryCallback<T> callback)
StackMob.isLoggedIn()).
classOfT - The class of the user modelcallback - The callback to invoke with the user model
public static <T extends StackMobUser> void getLoggedInUser(Class<T> classOfT,
StackMobOptions options,
StackMobQueryCallback<T> callback)
StackMob.isLoggedIn()).
classOfT - The class of the user modeloptions - Additional options, such as headers, to modify the requestcallback - The callback to invoke with the user model@Deprecated public static String getLoggedInUsername()
StackMob#getLoggedInUser(com.stackmob.sdk.callback.StackMobCallback) should be used instead.
public String getSchemaName()
StackMobModel
public static String overrideSchemaName() {
return "thenameyouwant";
}
The static method is necessary for the name to be accessible from
static method By default it's the name of the class in lower case.
Must be less than 25 alphanumeric characters.
getSchemaName in class StackMobModelpublic String getIDFieldName()
StackMobModel
getIDFieldName in class StackMobModelpublic String getUsername()
protected void login(Map<String,String> args,
StackMobOptions options,
StackMobCallback callback)
args - Key/value pair argumentsoptions - Additional options, such as headers, to modify the requestcallback - Invoked on completed login attemptpublic void login(StackMobCallback callback)
callback - Invoked on completed login attempt
public void login(StackMobOptions options,
StackMobCallback callback)
options - Additional options, such as headers, to modify the requestcallback - Invoked on completed login attempt
public void loginResettingTemporaryPassword(String newPassword,
StackMobCallback callback)
StackMobRawCallback.temporaryPasswordResetRequired(com.stackmob.sdk.exception.StackMobException)
callback is called. This is used as part of the forgot password flow.
callback - Invoked on completed login attempt
public void loginResettingTemporaryPassword(String newPassword,
StackMobOptions options,
StackMobCallback callback)
StackMobRawCallback.temporaryPasswordResetRequired(com.stackmob.sdk.exception.StackMobException)
callback is called. This is used as part of the forgot password flow.
options - Additional options, such as headers, to modify the requestcallback - Invoked on completed login attempt
public void loginWithFacebook(String facebookToken,
StackMobCallback callback)
createWithFacebook(String, com.stackmob.sdk.callback.StackMobCallback) or
linkWithFacebook(String, com.stackmob.sdk.callback.StackMobCallback).
facebookToken - The facebook user tokencallback - Callback to be called when the server returns. may execute in a separate thread
public void loginWithFacebook(String facebookToken,
boolean createUser,
String username,
StackMobOptions options,
StackMobCallback callback)
createWithFacebook(String, com.stackmob.sdk.callback.StackMobCallback) or
linkWithFacebook(String, com.stackmob.sdk.callback.StackMobCallback).
facebookToken - The facebook user tokencreateUser - Pass true to create a new user if no existing user is associated with the provided token. This works with OAuth2 only.username - If createUser is true, the primary key (username) to give the created user.options - Additional options, such as headers, to modify the requestcallback - Callback to be called when the server returns. may execute in a separate thread
public void loginWithTwitter(String twitterToken,
String twitterSecret,
StackMobCallback callback)
createWithTwitter(String, String, com.stackmob.sdk.callback.StackMobCallback) or
linkWithTwitter(String, String, com.stackmob.sdk.callback.StackMobCallback).
twitterToken - The twitter session key (this is a per user key - different from the consumer key)twitterSecret - The twitter session secret (this is a per user secret - different from the consumer secret)callback - Callback to be called when the server returns. may execute in a separate thread
public void loginWithTwitter(String twitterToken,
String twitterSecret,
boolean createUser,
String username,
StackMobOptions options,
StackMobCallback callback)
createWithTwitter(String, String, com.stackmob.sdk.callback.StackMobCallback) or
linkWithTwitter(String, String, com.stackmob.sdk.callback.StackMobCallback).
twitterToken - The twitter session key (this is a per user key - different from the consumer key)twitterSecret - The twitter session secret (this is a per user secret - different from the consumer secret)createUser - Pass true to create a new user if no existing user is associated with the provided tokens. This works with OAuth2 only.username - If createUser is true, the primary key (username) to give the created user.options - Additional options, such as headers, to modify the requestcallback - Callback to be called when the server returns. may execute in a separate thread
public void loginWithGigya(String gigyaUid,
String timestamp,
String sig,
StackMobOptions options,
StackMobCallback callback)
gigyaUid - The parameter UIDtimestamp - The parameter signatureTimestampsig - The parameter UIDSignatureoptions - Additional options, such as headers, to modify the requestcallback - Callback to be called when the server returns. may execute in a separate threadpublic void refreshLogin(StackMobCallback callback)
callback - Callback to be called when the server returns. may execute in a separate threadpublic void logout(StackMobCallback callback)
callback - invoked when logout is completepublic boolean isLoggedIn()
public boolean refreshRequired()
refreshLogin(com.stackmob.sdk.callback.StackMobCallback) call is required
to continue making authenticated requests. This will happen automatically, so there's no reason to
check this method unless you're overriding the existing refresh token system. If there are no credentials
at all this will be false.
public void createWithFacebook(String facebookToken,
StackMobCallback callback)
facebookToken - The facebook user tokencallback - Callback to be called when the server returns. may execute in a separate thread
public void createWithTwitter(String twitterToken,
String twitterSecret,
StackMobCallback callback)
twitterToken - The twitter session key (this is a per user key - different from the consumer key)twitterSecret - The twitter session secret (this is a per user secret - different from the consumer secret)callback - Callback to be called when the server returns. May execute in a separate thread
public void linkWithFacebook(String facebookToken,
StackMobCallback callback)
facebookToken - The Facebook user tokencallback - Callback to be called when the server returns. may execute in a separate threadpublic void unlinkFromFacebook(StackMobCallback callback)
callback - Callback to be called when the server returns. May execute in a separate thread.
public void linkWithTwitter(String twitterToken,
String twitterSecret,
StackMobCallback callback)
twitterToken - The twitter session key (this is a per user key - different from the consumer key)twitterSecret - The twitter session secret (this is a per user secret - different from the consumer secret)callback - Callback to be called when the server returns. may execute in a separate threadpublic void unlinkFromTwitter(StackMobCallback callback)
callback - Callback to be called when the server returns. May execute in a separate thread.
public void postFacebookMessage(String msg,
StackMobRawCallback callback)
msg - The message to postcallback - Callback to be called when the server returns. may execute in a separate thread
public void postTwitterUpdate(String message,
StackMobRawCallback callback)
message - The message to send. must be <= 140 characterscallback - Callback to be called when the server returns. may execute in a separate threadpublic void getFacebookUserInfo(StackMobRawCallback callback)
callback - Callback to be called when the server returns. may execute in a separate threadpublic void getTwitterUserInfo(StackMobRawCallback callback)
callback - Callback to be called when the server returns. May execute in a separate thread
public void resetPassword(String oldPassword,
String newPassword,
StackMobCallback callback)
oldPassword - The users' old passwordnewPassword - The new passwordcallback - Invoked upon completed reset
public void registerForPush(StackMobPushToken token,
StackMobRawCallback callback)
token - The Android registration id to associate with this usercallback - Invoked when the operation is complete
public void sendPush(Map<String,String> payload,
StackMobRawCallback callback)
payload - The message to sendcallback - Invoked when the operation is complete
public void removeFromPush(StackMobPushToken token,
StackMobRawCallback callback)
token - The token to removecallback - Invoked when the operation is completepublic void getPushTokens(StackMobRawCallback callback)
callback - Invoked when the operation is complete
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||