|
||||||||||
| 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.
| 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 thsi 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()
get the username for the logged in user, if one exists |
|
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 an user with an existing Facebook user via Facebook credentials. |
|
void |
linkWithTwitter(String twitterToken,
String twitterSecret,
StackMobCallback callback)
link an 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,
StackMobCallback callback)
login to StackMob with Facebook credentials. |
|
void |
loginWithFacebook(String facebookToken,
StackMobOptions options,
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,
StackMobCallback callback)
login to StackMob with twitter credentials. |
|
void |
loginWithTwitter(String twitterToken,
String twitterSecret,
StackMobOptions options,
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 users’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 |
|
| Methods inherited from class com.stackmob.sdk.model.StackMobModel |
|---|
append, appendAndSave, count, destroy, destroy, fetch, fetch, fillFromJson, getID, hasData, newFromJson, query, query, remove, removeAndDelete, save, save, save, saveMultiple, setID, toJson, toJson |
| 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 modelpublic static String getLoggedInUsername()
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,
StackMobOptions options,
StackMobCallback callback)
createWithFacebook(String, com.stackmob.sdk.callback.StackMobCallback) or
linkWithFacebook(String, com.stackmob.sdk.callback.StackMobCallback)
facebookToken - the facebook user tokenoptions - 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,
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)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 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 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 | |||||||||