Package im.getsocial.sdk
Class GetSocial
- java.lang.Object
-
- im.getsocial.sdk.GetSocial
-
public final class GetSocial extends java.lang.Object
Class contains main part of exposed GetSocial API.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GetSocial.Device
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
addOnCurrentUserChangedListener(OnCurrentUserChangedListener listener)
Add listener to be notified when the user was changed.static void
addOnInitializeListener(java.lang.Runnable action)
Set an action, which should be executed after SDK initialized.static CurrentUser
getCurrentUser()
Current user.static java.lang.String
getLanguage()
static java.lang.String
getSdkVersion()
The version of GetSocial SDK.static void
handle(Action action)
Process action with default GetSocial behaviour.static void
init()
Init the SDK.static void
init(Identity identity, CompletionCallback callback, FailureCallback failureCallback)
static void
init(java.lang.String appId)
Init the SDK.static boolean
isInitialized()
Provides the status of the GetSocial initialisation.static void
removeOnUserChangedListener(java.lang.String listenerId)
Remove listener with id.static void
reset(CompletionCallback callback, FailureCallback failure)
Reset the current user without creating a new anonymous one.static void
resetUser(CompletionCallback callback, FailureCallback failure)
Reset current user and create a new anonymous one.static boolean
setLanguage(java.lang.String languageCode)
Set the language of GetSocial SDK.static void
switchUser(Identity identity, CompletionCallback callback, FailureCallback failure)
Switches the current user with theUser
corresponding to the details provided.
-
-
-
Method Detail
-
addOnCurrentUserChangedListener
public static java.lang.String addOnCurrentUserChangedListener(OnCurrentUserChangedListener listener)
Add listener to be notified when the user was changed. The listener action is executed on the main thread, so be careful with operations, that you put inside onOnCurrentUserChangedListener.onUserChanged(CurrentUser)
method. Listener will be invoked when: - SDK initialization is finished; -switchUser(im.getsocial.sdk.communities.Identity, im.getsocial.sdk.CompletionCallback, im.getsocial.sdk.FailureCallback)
method was called and user was successfully changed.- Parameters:
listener
- Listener to be notified.- Returns:
- the listener ID you can pass later to
removeOnUserChangedListener(String)
.
-
removeOnUserChangedListener
public static void removeOnUserChangedListener(java.lang.String listenerId)
Remove listener with id.- Parameters:
listenerId
- ID of listener you want to remove. It should be the string returned byaddOnCurrentUserChangedListener(OnCurrentUserChangedListener)
-
getCurrentUser
public static CurrentUser getCurrentUser()
Current user.- Returns:
- current user or null if SDK is not initialized.
-
switchUser
public static void switchUser(Identity identity, CompletionCallback callback, FailureCallback failure)
Switches the current user with theUser
corresponding to the details provided.- Parameters:
identity
- Identity to be switched to.callback
- A callback to indicate if this operation was successful.failure
- Called if operation failed.
-
resetUser
public static void resetUser(CompletionCallback callback, FailureCallback failure)
Reset current user and create a new anonymous one.- Parameters:
callback
- called if successfully reset user.failure
- called if operation failed.
-
reset
public static void reset(CompletionCallback callback, FailureCallback failure)
Reset the current user without creating a new anonymous one. The SDK is uninitialized.- Parameters:
callback
- called if successfully reset the user.failure
- called if operation failed.
-
getSdkVersion
public static java.lang.String getSdkVersion()
The version of GetSocial SDK.- Returns:
String
value of the SDK version.
-
init
public static void init()
Init the SDK. UseaddOnInitializeListener(Runnable)
to be notified when SDK is initialized. GetSocial App Id will be taken from AndroidManifest.xml metadata.
-
init
public static void init(java.lang.String appId)
Init the SDK. UseaddOnInitializeListener(Runnable)
to be notified when SDK is initialized.- Parameters:
appId
- GetSocial App Id. You can find your App Id on the GetSocial Dashboard.
-
init
public static void init(Identity identity, CompletionCallback callback, FailureCallback failureCallback)
-
addOnInitializeListener
public static void addOnInitializeListener(java.lang.Runnable action)
Set an action, which should be executed after SDK initialized. Executed immediately, if SDK is already initialized.- Parameters:
action
- Action to execute.
-
isInitialized
public static boolean isInitialized()
Provides the status of the GetSocial initialisation.- Returns:
- true if GetSocial initialization has completed successfully.
-
getLanguage
public static java.lang.String getLanguage()
- Returns:
- current language of GetSocial SDK, return value is one of language codes provided
in
LanguageCodes
, or default language in case of failure.
-
setLanguage
public static boolean setLanguage(java.lang.String languageCode)
Set the language of GetSocial SDK. If language is incorrect, default language is set.- Parameters:
languageCode
- Must be one of language codes provided inLanguageCodes
- Returns:
- true if the operation was successful, false otherwise
-
handle
public static void handle(Action action)
Process action with default GetSocial behaviour.- Parameters:
action
- action to be processed.
-
-