public final class CaptainUp
extends java.lang.Object
addListener(CaptainUpListener)
with ConnectionCaptainUpListener
and
AuthenticateCaptainUpListener
connect(Context, int)
ConnectionCaptainUpListener.onAfterConnect(Application)
, authenticate
you App's user with captain up, using authenticate(IntegrationUser)
AuthenticateCaptainUpListener.onAuthenticationDone(ActionableUser)
you can get the logged in user, perform action on it, and listen to its eventsModifier and Type | Method and Description |
---|---|
static void |
addListener(CaptainUpListener listener)
Adds a listener to Captain Up events.
|
static void |
authenticate(android.content.Context context,
int configId,
IntegrationUser user)
Connects and Authenticates a user to Captain Up.
|
static void |
authenticate(IntegrationUser user)
Authenticates a user to Captain Up.
|
static void |
connect(android.content.Context context,
int configId)
Initializes Captain Up objects.
|
static void |
disconnect()
Disconnect from Captain Up.
|
static Application |
getApplication()
Returns all the current connected application's settings, including information on the action
settings, levels, badges and etc.
|
static android.content.Context |
getContext() |
static ActionableUser |
getLoggedInUser()
Returns the logged in user.
|
static CaptainUpProperties |
getProperties()
Get the Captain Up properties
|
static java.util.Map<java.lang.String,Badge> |
getSegmentedBadges() |
static void |
getUser(java.lang.String userId,
CaptainUpCallback<User> callback) |
static boolean |
isAuthenticated()
Checks whether or not you already authenticated a user with the Captain Up SDK.
|
static boolean |
isConnected()
Checks whether or not you are already connected to Captain Up.
|
static void |
queryLeaderboard(LeaderboardTime time,
java.lang.String playerId,
Query query,
CaptainUpCallback<LeaderboardCaptainUpResponse> callback) |
static void |
querySocialFeed(CaptainUpCallback<GetSocialFeedCaptainUpResponse> callback) |
static void |
refresh()
Refreshes the Captain Up connection and logged in user (if any).
|
static void |
removeListener(CaptainUpListener listener)
Removes a listener from this user instance.
|
static void |
SetLanguageCode(java.lang.String languageCode)
Sets the application language, use this function to set your user localization.
|
public static void addListener(CaptainUpListener listener)
listener
parameter.
Supported events:
ConnectionCaptainUpListener
AuthenticateCaptainUpListener
listener
- any object implementing CaptainUpListener
. The listener
can implement multiple interfaces and thus will be registered to all events it supports.public static void removeListener(CaptainUpListener listener)
listener
- the listener object to be removed.public static boolean isConnected()
true
if and only if you are already connected to Captain Up.connect(Context, int)
public static void connect(android.content.Context context, int configId) throws ConfigFileCaptainUpException
authenticate(IntegrationUser)
). If the connection succeeds and there's a
ConnectionCaptainUpListener
registered, the onAfterConnect will be called.
If there was an error connection, and there's a ErrorCaptainUpListener
registered, the onError will be called. Make sure you call addListener(CaptainUpListener)
before connect.
For most cases, there's no need to distinguish between the "connect" and "authenticate" flows.
Consider using authenticate(Context, int, IntegrationUser)
instead.context
- your app's contextconfigId
- the id of the captain up configuration. By default use R.raw.captainup_config.ConfigFileCaptainUpException
- thrown if there's an error reading the configuration filejava.lang.IllegalStateException
- thrown if you tried calling connect after a previous successful call to connectauthenticate(Context, int, IntegrationUser)
public static void disconnect()
authenticate(Context, int, IntegrationUser)
with your new user id.
Remember to add listenerspublic static void authenticate(IntegrationUser user)
AuthenticateCaptainUpListener
registered,
the onAuthenticationDone will be called. If there was an error connection, and there's a
ErrorCaptainUpListener
registered, the
onError will be called.
Must be called after a successful call to connect(Context, int)
.
CaptainUpConnection.authenticate(User)
).user
- the user to authenticate and log in.java.lang.IllegalStateException
- thrown if trying to authenticate before a call to connect(Context, int)
authenticate(Context, int, IntegrationUser)
public static void authenticate(android.content.Context context, int configId, IntegrationUser user)
ConnectionCaptainUpListener
registered, the onAfterConnect will be called.
If the user does not exist in Captain Up yet, it will be created.
In any case, if the authentication was successful and there is a
AuthenticateCaptainUpListener
registered,
the onAuthenticationDone will be called.
If there was an error connection, and there's a ErrorCaptainUpListener
registered, the onError will be called. Make sure you call addListener(CaptainUpListener)
before connect.
CaptainUpConnection.authenticate(User)
).context
- your app's contextconfigId
- the id of the captain up configuration. By default use R.raw.captainup_config.user
- the user to authenticate and log in.public static boolean isAuthenticated()
true
if and only if you successfully authenticated a user.authenticate(IntegrationUser)
public static void queryLeaderboard(LeaderboardTime time, java.lang.String playerId, Query query, CaptainUpCallback<LeaderboardCaptainUpResponse> callback)
public static void querySocialFeed(CaptainUpCallback<GetSocialFeedCaptainUpResponse> callback)
public static Application getApplication()
connect(Context, int)
must have completed successfully before calling this method.java.lang.IllegalStateException
- thrown when the called before connect(Context, int)
or if it failedpublic static void getUser(java.lang.String userId, CaptainUpCallback<User> callback)
public static ActionableUser getLoggedInUser()
authenticated
a user, any pending actions will be sent and processed and any events will be raised accordingly.
Note: if the was a disconnect (for exmaple, the client's network is down), after a successful
connection, the user will contain the latest information we've got. Any actions performed while
in this "disconnect" state will generate errors (ErrorCaptainUpUserListener
).
It is your responsibility to aggregate these failed actions and they will not be retried.public static void refresh()
ActionableUser
instance. Any listeners connected to the user will be invoked to
reflect changed because of the update.
This is an asynchronous operation that will trigger listeners. Once the refresh is done the
AuthenticateCaptainUpListener
will be invoked.public static android.content.Context getContext()
public static CaptainUpProperties getProperties()
null
if Captain Up is not initializedpublic static void SetLanguageCode(java.lang.String languageCode)
languageCode
- the user language codepublic static java.util.Map<java.lang.String,Badge> getSegmentedBadges()