-
public final class SendBird
SendBird Main Class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enum
SendBird.ConnectionState
SDK connection state.
public class
SendBird.Options
Represents operation options.
public interface
SendBird.ConnectHandler
Connect handler. This handler provides callback for connect and connect.
public abstract class
SendBird.ChannelHandler
Channel handler. This handler provides callbacks for events related
OpenChannel
orGroupChannel
.All callbacks are called only when the currently logged-inUser
is a participant or member ofOpenChannel
orGroupChannel
respectively.To add or remove this handler, refer to addChannelHandler and removeChannelHandler.public abstract class
SendBird.UserEventHandler
User event handler.To add or remove this handler, refer to addUserEventHandler and removeUserEventHandler.
public interface
SendBird.ConnectionHandler
Connection handler. This handler provides callbacks for automatically managed reconnection events.SendBird tries reconnection when the connection is lost. This handler can be used to track the reconnection state.To add or remove this handler, refer to addConnectionHandler and removeConnectionHandler.
public interface
SendBird.DisconnectHandler
Disconnect handler. This handler provides callback for disconnect.
public enum
SendBird.PushTokenType
PushTokenType.
public enum
SendBird.PushTriggerOption
PushTriggerOption of the current
User
. Refer to setPushTriggerOption.public class
SendBird.HMS
Push token related class specifically for Huawei Message Service, HMS.
public enum
SendBird.PushTokenRegistrationStatus
Status of push token registration. If connection is not made when token is requested to be registered,
PENDING
will be returned at callback handler. The registration is available after the connection is establishedby calling registerPushTokenForCurrentUser with getPendingPushToken for GCM,or registerPushTokenForCurrentUser with getPendingPushToken for HMS.public interface
SendBird.RegisterPushTokenHandler
RegisterPushToken handler. This handler provides callback for registerPushTokenForCurrentUser.
public interface
SendBird.RegisterPushTokenWithStatusHandler
RegisterPushTokenWithStatus handler. This handler provides callback for registerPushTokenForCurrentUser.
public interface
SendBird.UnregisterPushTokenHandler
UnregisterPushToken handler. This handler provides callback for unregisterPushTokenForCurrentUser and unregisterPushTokenAllForCurrentUser.
public interface
SendBird.GetPushTokensHandler
GetPushTokens handler. This handler provides callback for getMyPushTokensByToken.
public interface
SendBird.SetDoNotDisturbHandler
SetDoNotDisturb handler. This handler provides callback for setDoNotDisturb.
public interface
SendBird.GetDoNotDisturbHandler
GetDoNotDisturb handler. This handler provides callback for getDoNotDisturb.
public interface
SendBird.SetSnoozePeriodHandler
SetSnoozePeriodHandler handler. This handler provides callback for setSnoozePeriod.
public interface
SendBird.GetSnoozePeriodHandler
GetSnoozePeriodHandler handler. This handler provides callback for getSnoozePeriod.
public interface
SendBird.SetPushSoundHandler
SetPushSound handler. This handler provides callback for setPushSound.
public interface
SendBird.GetPushSoundHandler
GetPushSound handler. This handler provides callback for getPushSound.
public interface
SendBird.SetPushTemplateHandler
SetPushTemplate handler. This handler provides callback for setPushTemplate.
public interface
SendBird.GetPushTemplateHandler
GetPushTemplate handler. This handler provides callback for getPushTemplate.
public interface
SendBird.SetPushTriggerOptionHandler
SetPushTriggerOptionHandler handler. This handler provides callback for setPushTriggerOption.
public interface
SendBird.GetPushTriggerOptionHandler
GetPushTriggerOptionHandler handler. This handler provides callback for getPushTriggerOption.
public interface
SendBird.UserInfoUpdateHandler
UserInfoUpdate handler. This provides callback for updateCurrentUserInfo and updateCurrentUserInfoWithProfileImage.
public interface
SendBird.SetChannelInvitationPreferenceHandler
SetAutoAcceptInvitation handler.This provides callback for setChannelInvitationPreference.
public interface
SendBird.GetChannelInvitationPreferenceHandler
GetAutoAcceptInvitation handler.This provides callback for getChannelInvitationPreference.
public interface
SendBird.UserBlockHandler
UserBlock handler. This provides callback for blockUser and blockUserWithUserId.
public interface
SendBird.UserUnblockHandler
UserUnblock handler. This provides callback for unblockUser and unblockUserWithUserId.
public interface
SendBird.AddFriendsHandler
AddFriendsHandler handler. This handler provides callback for addFriends.
public interface
SendBird.DeleteFriendsHandler
DeleteFriendsHandler handler. This handler provides callback for deleteFriends.
public interface
SendBird.DeleteFriendHandler
DeleteFriendHandler handler. This handler provides callback for deleteFriend.
public interface
SendBird.UploadFriendDiscoveriesHandler
UploadFriendDiscoveriesHandler handler. This handler provides callback for uploadFriendDiscoveries.
public interface
SendBird.DeleteFriendDiscoveriesHandler
DeleteFriendDiscoveriesHandler handler. This handler provides callback for deleteFriendDiscoveries.
public interface
SendBird.DeleteFriendDiscoveryHandler
DeleteFriendDiscoveryHandler handler. This handler provides callback for deleteFriendDiscovery.
public interface
SendBird.GetFriendChangeLogsByTokenHandler
GetFriendChangeLogsByTokenHandler handler. This handler provides callback for getFriendChangeLogsByToken.
public interface
SendBird.GetMyGroupChannelChangeLogsHandler
GetMyGroupChannelChangeLogsHandler handler. This handler provides callback for all getting channel changelogs related methods.
public interface
SendBird.MarkAsReadHandler
GroupChannelMarkAsRead handler. This handler provides callback for markAsReadAll.
public interface
SendBird.GetAllEmojiHandler
getAllEmoji handler. This handler provides callback for getAllEmoji.
public interface
SendBird.GetEmojiCategoryHandler
getEmojiCategory handler. This handler provides callback for getEmojiCategory.
public interface
SendBird.GetEmojiHandler
getEmoji handler. This handler provides callback for getEmoji.
-
Field Summary
Fields Modifier and Type Field Description private final static AtomicReference<String>
appVersion
private static String
ekey
private SessionHandler
sessionHandler
public final static int
LOGGER_NONE
public final static int
LOGGER_INFO
public final static String
PUSH_TEMPLATE_DEFAULT
public final static String
PUSH_TEMPLATE_ALTERNATIVE
-
Method Summary
Modifier and Type Method Description static void
setAppVersion(@NonNull() String version)
Sets the app version. static String
getEkey()
Gets the key to authenticate the url retrieved from getPlainUrl, getPlainProfileImageUrl and getPlainUrl.This key has to be put into the HTTP header to access the url provided by above methods. static void
setEkey(String ekey)
static SessionHandler
getSessionHandler()
static void
setSessionHandler(SessionHandler sessionHandler)
Set a SessionHandler which is required for SDK refresh the session when the current session expires. static void
addExtension(String key, String version)
To send additional User-Agent information please set the version information.This will be set pre-defined keys only. static void
runOnUIThread(Runnable runnable)
static String
getOSVersion()
Returns current OS version. static String
getSDKVersion()
Returns current SDK version. static String
getApplicationId()
Returns current application ID. static void
setLoggerLevel(int level)
Sets logger level. static void
setLoggerLevel(LogLevel logLevel)
As of 3.0.153, Sets the logger level for server request/response related logs. static synchronized void
init(String appId, Context context, boolean useCaching, @NonNull() InitResultHandler handler)
Initializes SendBird with given app ID. static void
clearCachedData(@NonNull() Context context, @Nullable() CompletionHandler handler)
Clears the db data used in local caching. static void
clearCachedMessages(@NonNull() String channelUrl, @Nullable() CompletionHandler handler)
Clear cached messages of specific channel. static Long
getCachedDataSize(@NonNull() Context context)
Gets the size of cached data. static boolean
init(@NonNull() String appId, @NonNull() Context context)
Initializes SendBird with given app ID. static synchronized boolean
initFromForeground(@NonNull() String appId, @NonNull() Context context)
Initializes SendBird with given app ID.It will set the application state to FOREGROUND. static synchronized void
initFromForeground(@NonNull() String appId, @NonNull() Context context, boolean useCaching, @NonNull() InitResultHandler handler)
Initializes SendBird with given app ID.It will set the application state to FOREGROUND. static boolean
isUsingLocalCaching()
Returns whether the app uses local caching. static void
notifyActivityResumedForOldAndroids()
Notifies SendBird of the current Activity
being started.static void
notifyActivityPausedForOldAndroids()
Notifies SendBird of the current Activity
being paused.static void
setAutoBackgroundDetection(boolean enable)
Sets SendBird to detect if the Application
is in background automatically.static boolean
getAutoBackgroundDetection()
Gets SendBird auto background detection status. static void
setNetworkAwarenessReconnection(boolean enable)
Sets SendBird to reconnect automatically by network awareness. static boolean
getNetworkAwarenessReconnection()
Gets SendBird network awareness reconnection status. static SendBird.ConnectionState
getConnectionState()
Gets SDK connection state. static void
connect(String userId, SendBird.ConnectHandler handler)
Connects to SendBird with given User
ID.static void
connect(String userId, String accessToken, SendBird.ConnectHandler handler)
Connects to SendBird with given User
ID and access token.static void
connect(String userId, String accessToken, String apiHost, String wsHost, SendBird.ConnectHandler handler)
Connects to SendBird with given User
ID and access token.static boolean
reconnect()
Tries reconnection with previously and successfully connected user information. static void
addChannelHandler(String identifier, SendBird.ChannelHandler handler)
Adds a channel handler. static SendBird.ChannelHandler
removeChannelHandler(String identifier)
Removes a channel handler. static void
removeAllChannelHandlers()
Removes all channel handlers added by addChannelHandler. static void
addUserEventHandler(String identifier, SendBird.UserEventHandler handler)
Adds a user event handler. static SendBird.UserEventHandler
removeUserEventHandler(String identifier)
Removes a user event handler. static void
removeAllUserEventHandlers()
Removes all user event handlers added by addUserEventHandler. static void
addConnectionHandler(String identifier, SendBird.ConnectionHandler handler)
Adds a connection handler. static SendBird.ConnectionHandler
removeConnectionHandler(String identifier)
Removes a connection handler. static void
removeAllConnectionHandlers()
Removes all connection handlers added by addConnectionHandler. static void
disconnect(SendBird.DisconnectHandler handler)
Disconnects from SendBird. static AppInfo
getAppInfo()
Returns obtain information on the set application settings. static User
getCurrentUser()
Gets the current User
.static long
getLastConnectedAt()
Gets the last connected timestamp. static UserListQuery
createUserListQuery()
Creates a query instance to get the whole User
list.static UserListQuery
createUserListQuery(List<String> userIds)
Creates a query instance to get the filtered User
list byUser
IDs.static ApplicationUserListQuery
createApplicationUserListQuery()
Creates a query instance to get the whole User
list.static BlockedUserListQuery
createBlockedUserListQuery()
Creates a query instance to get only the blocked User
(by me) list.static void
updateCurrentUserInfoWithProfileImage(String nickname, File profileImage, SendBird.UserInfoUpdateHandler handler)
Updates current User
's information.static void
updateCurrentUserInfo(String nickname, String profileUrl, SendBird.UserInfoUpdateHandler handler)
Updates current User
's information.static void
updateCurrentUserInfo(List<String> preferredLanguages, SendBird.UserInfoUpdateHandler handler)
Updates current User
's information.static String
getPendingPushToken()
Gets the pending push token. static void
registerPushTokenForCurrentUser(String gcmRegToken, SendBird.RegisterPushTokenHandler handler)
Registers push token for the current User
to receive push notification.static void
registerPushTokenForCurrentUser(String gcmRegToken, SendBird.RegisterPushTokenWithStatusHandler handler)
Registers push token for the current User
to receive push notification.static void
registerPushTokenForCurrentUser(String gcmRegToken, boolean unique, SendBird.RegisterPushTokenWithStatusHandler handler)
Registers push token for the current User
to receive push notification.static void
unregisterPushTokenForCurrentUser(String gcmRegToken, SendBird.UnregisterPushTokenHandler handler)
Unregisters push token for the current User
.static void
unregisterPushTokenAllForCurrentUser(SendBird.UnregisterPushTokenHandler handler)
Unregisters all push token bound to the current User
.static void
getMyPushTokensByToken(String token, SendBird.PushTokenType type, SendBird.GetPushTokensHandler handler)
Requests push tokens of current user from given token. static void
setDoNotDisturb(boolean doNotDisturbOn, int startHour, int startMin, int endHour, int endMin, String timezone, SendBird.SetDoNotDisturbHandler handler)
Sets Do-not-disturb option for the current User
.static void
getDoNotDisturb(SendBird.GetDoNotDisturbHandler handler)
Gets Do-not-disturb option for the current User
.static void
setSnoozePeriod(boolean snoozeOn, long startTs, long endTs, SendBird.SetSnoozePeriodHandler handler)
Sets snooze period for the current User
.static void
getSnoozePeriod(SendBird.GetSnoozePeriodHandler handler)
Gets snooze period for the current User
.static void
setPushSound(String sound, SendBird.SetPushSoundHandler handler)
Sets the push notification sound file path for the current User
.This setting will be delivered on push notification payload.static void
getPushSound(SendBird.GetPushSoundHandler handler)
Gets push notification sound path for the current User
.static void
setPushTemplate(String templateName, SendBird.SetPushTemplateHandler handler)
Sets push template option for the current User
.static void
getPushTemplate(SendBird.GetPushTemplateHandler handler)
Gets push template option for the current User
.static void
setPushTriggerOption(SendBird.PushTriggerOption pushTriggerOption, SendBird.SetPushTriggerOptionHandler handler)
Sets the current User
's push trigger option.static void
getPushTriggerOption(SendBird.GetPushTriggerOptionHandler handler)
Gets the current User
's push trigger option.static void
setChannelInvitationPreference(boolean autoAccept, SendBird.SetChannelInvitationPreferenceHandler handler)
Sets the current User
's preference forGroupChannel
join.static void
getChannelInvitationPreference(SendBird.GetChannelInvitationPreferenceHandler handler)
Gets the current User
's preference forGroupChannel
join.static void
blockUser(User userToBlock, SendBird.UserBlockHandler handler)
Blocks the specified User
.static void
blockUserWithUserId(String userIdToBlock, SendBird.UserBlockHandler handler)
Blocks the specified User
ID.static void
unblockUser(User blockedUser, SendBird.UserUnblockHandler handler)
Unblocks the specified User
.static void
unblockUserWithUserId(String blockedUserId, SendBird.UserUnblockHandler handler)
Unblocks the specified User
ID.static void
addFriends(List<String> userIds, SendBird.AddFriendsHandler handler)
Add friends. static void
deleteFriends(List<String> userIds, SendBird.DeleteFriendsHandler handler)
Delete friends. static void
deleteFriend(String userId, SendBird.DeleteFriendHandler handler)
Delete friend. static void
uploadFriendDiscoveries(Map<String, String> discoveryMap, SendBird.UploadFriendDiscoveriesHandler handler)
Upload friend discoveries. static void
deleteFriendDiscoveries(List<String> discoveryKeys, SendBird.DeleteFriendDiscoveriesHandler handler)
Delete friend discoveries. static void
deleteFriendDiscovery(String discoveryKey, SendBird.DeleteFriendDiscoveryHandler handler)
Delete friend discovery. static void
getFriendChangeLogsByToken(String token, SendBird.GetFriendChangeLogsByTokenHandler handler)
Get friend changelogs by token. static FriendListQuery
createFriendListQuery()
Creates a query instance to get friends. static void
getMyGroupChannelChangeLogsByToken(String token, List<String> customTypes, SendBird.GetMyGroupChannelChangeLogsHandler handler)
Requests the channel changelogs from given token. static void
getMyGroupChannelChangeLogsByTimestamp(long ts, List<String> customTypes, SendBird.GetMyGroupChannelChangeLogsHandler handler)
Requests the channel changelogs after given timestamp. static void
getMyGroupChannelChangeLogsByToken(String token, List<String> customTypes, boolean includeEmpty, SendBird.GetMyGroupChannelChangeLogsHandler handler)
Requests the channel changelogs from given token. static void
getMyGroupChannelChangeLogsByTimestamp(long ts, List<String> customTypes, boolean includeEmpty, SendBird.GetMyGroupChannelChangeLogsHandler handler)
Requests the channel changelogs after given timestamp. static void
getMyGroupChannelChangeLogsByTokenWithParams(String token, GroupChannelChangeLogsParams params, SendBird.GetMyGroupChannelChangeLogsHandler handler)
Requests the channel changelogs from given token. static void
getMyGroupChannelChangeLogsByTimestampWithParams(long ts, GroupChannelChangeLogsParams params, SendBird.GetMyGroupChannelChangeLogsHandler handler)
Requests the channel changelogs after given timestamp. static void
markAsDelivered(String channelUrl)
Sends mark as delivered to this channel when you received push message from us. static void
markAsDelivered(Map<String, String> data)
Sends mark as delivered to this channel when you received push message from us. static void
markAsReadAll(SendBird.MarkAsReadHandler handler)
Sends mark as read to all joined GroupChannel
s.This method has rate limit.static void
markAsReadWithChannelUrls(List<String> channelUrls, SendBird.MarkAsReadHandler handler)
Sends mark as read to joined GroupChannel
s.This method has rate limit.static void
getAllEmoji(SendBird.GetAllEmojiHandler handler)
Requests the all emoji. static void
getEmojiCategory(long emojiCategoryId, SendBird.GetEmojiCategoryHandler handler)
Requests the emoji category. static void
getEmoji(String key, SendBird.GetEmojiHandler handler)
Requests the emoji. static void
getTotalUnreadMessageCount(GroupChannel.GroupChannelTotalUnreadMessageCountHandler handler)
Gets the total number of unread message of all GroupChannel
s the current user has joined.static void
getTotalUnreadMessageCount(List<String> channelCustomTypes, GroupChannel.GroupChannelTotalUnreadMessageCountHandler handler)
Gets the total number of unread message of GroupChannel
s with channel custom types filter.static void
getTotalUnreadMessageCount(GroupChannelTotalUnreadMessageCountParams params, GroupChannel.GroupChannelTotalUnreadMessageCountHandler handler)
Gets the total number of unread message of GroupChannel
s withGroupChannelTotalUnreadMessageCountParams
filter.static int
getSubscribedTotalUnreadMessageCount()
Gets the subscribed total number of unread message of all GroupChannel
s the current user has joined.static int
getSubscribedCustomTypeTotalUnreadMessageCount()
Gets the total number of unread message of GroupChannel
s with subscribed custom types.static int
getSubscribedCustomTypeUnreadMessageCount(String customType)
Gets the number of unread message of GroupChannel
with subscribed custom type.static void
getUnreadItemCount(Collection<GroupChannel.UnreadItemKey> keys, GroupChannel.GroupChannelGetUnreadItemCountHandler handler)
Gets the unread item count of GroupChannel
s from keys.static void
getTotalUnreadChannelCount(GroupChannel.GroupChannelTotalUnreadChannelCountHandler handler)
Gets the total number of unread GroupChannel
s the current user has joined.static void
getTotalUnreadChannelCount(GroupChannelTotalUnreadChannelCountParams params, GroupChannel.GroupChannelTotalUnreadChannelCountHandler handler)
Gets the total number of unread GroupChannel
s the current user has joined.static void
getGroupChannelCount(GroupChannelListQuery.MemberStateFilter memberStateFilter, GroupChannel.GroupChannelChannelCountHandler handler)
Gets the number of my GroupChannel
s.static void
allowFriendDiscovery(boolean allow, AllowFriendDiscoveryHandler handler)
Sets friend discoverability of current user. static void
getAllowFriendDiscovery(GetAllowFriendDiscoveryHandler handler)
Gets friend discoverability of current user. -
-
Method Detail
-
setAppVersion
static void setAppVersion(@NonNull() String version)
Sets the app version.It's recommended to set the app version right after init.
- Parameters:
version
- The version of the app.
-
getEkey
static String getEkey()
Gets the key to authenticate the url retrieved from getPlainUrl, getPlainProfileImageUrl and getPlainUrl.This key has to be put into the HTTP header to access the url provided by above methods.
-
getSessionHandler
static SessionHandler getSessionHandler()
-
setSessionHandler
static void setSessionHandler(SessionHandler sessionHandler)
Set a SessionHandler which is required for SDK refresh the session when the current session expires.Must be set before the connection is made by connect, connect or connect.
- Parameters:
sessionHandler
- SessionHandler to handle session related events.
-
addExtension
static void addExtension(String key, String version)
To send additional User-Agent information please set the version information.This will be set pre-defined keys only.
- Parameters:
key
- KEY of value you want to send.version
- a value you want to send.
-
runOnUIThread
static void runOnUIThread(Runnable runnable)
-
getOSVersion
static String getOSVersion()
Returns current OS version.
-
getSDKVersion
static String getSDKVersion()
Returns current SDK version.
-
getApplicationId
static String getApplicationId()
Returns current application ID.
-
setLoggerLevel
static void setLoggerLevel(int level)
Sets logger level.
- Parameters:
level
- Level of logger.
-
setLoggerLevel
static void setLoggerLevel(LogLevel logLevel)
As of 3.0.153, Sets the logger level for server request/response related logs. Thescope of the log is subject to change.
- Parameters:
logLevel
- desired log level.
-
init
static synchronized void init(String appId, Context context, boolean useCaching, @NonNull() InitResultHandler handler)
Initializes SendBird with given app ID.
- Parameters:
appId
- Application ID which you can get by creating the application at SendBird Dashboard.context
-Context
ofApplication
.useCaching
- Determine whether to use database in the SDK.handler
- Handler to receive SendBird.init function call processing results.Application ID can be changed by calling this with different application IDs.Notice that only on CLOSED connection status application ID can be modified.
-
clearCachedData
static void clearCachedData(@NonNull() Context context, @Nullable() CompletionHandler handler)
Clears the db data used in local caching.If local caching is enabled, this should be called before init or initFromForeground.
- Parameters:
context
- Context.
-
clearCachedMessages
static void clearCachedMessages(@NonNull() String channelUrl, @Nullable() CompletionHandler handler)
Clear cached messages of specific channel.
- Parameters:
channelUrl
- target channel's url
-
getCachedDataSize
static Long getCachedDataSize(@NonNull() Context context)
Gets the size of cached data. If local caching is not used, return 0If you want to clear all cached data, call clearCachedData If you want to clear specific channel's cache, call clearCachedMessages
- Parameters:
context
- Context.
-
init
@Deprecated() static boolean init(@NonNull() String appId, @NonNull() Context context)
Initializes SendBird with given app ID.
- Parameters:
appId
- Application ID which you can get by creating the application at SendBird Dashboard.context
-Context
ofApplication
.
-
initFromForeground
@Deprecated() static synchronized boolean initFromForeground(@NonNull() String appId, @NonNull() Context context)
Initializes SendBird with given app ID.It will set the application state to FOREGROUND.
- Parameters:
appId
- Application ID which you can get by creating the application at SendBird Dashboard.context
-Context
ofApplication
.
-
initFromForeground
static synchronized void initFromForeground(@NonNull() String appId, @NonNull() Context context, boolean useCaching, @NonNull() InitResultHandler handler)
Initializes SendBird with given app ID.It will set the application state to FOREGROUND.
- Parameters:
appId
- Application ID which you can get by creating the application at SendBird Dashboard.context
-Context
ofApplication
.useCaching
- Determine whether to use local caching in the SDK.handler
- Handler to receive SendBird.init function call processing results.Application ID can be changed by calling this with different application IDs.Notice that only on CLOSED connection status application ID can be modified.
-
isUsingLocalCaching
static boolean isUsingLocalCaching()
Returns whether the app uses local caching.
-
notifyActivityResumedForOldAndroids
@Deprecated() static void notifyActivityResumedForOldAndroids()
Notifies SendBird of the current
Activity
being started.This MUST be called on every Activity#onResume() in the application,so that it can receive push notifications (GCM).If the application runs only above Android 4.0, this method can be ignored.
-
notifyActivityPausedForOldAndroids
@Deprecated() static void notifyActivityPausedForOldAndroids()
Notifies SendBird of the current
Activity
being paused.This MUST be called on every Activity#onPause() in the application,so that it can receive push notifications (GCM).If the application runs only above Android 4.0, this method can be ignored.
-
setAutoBackgroundDetection
static void setAutoBackgroundDetection(boolean enable)
Sets SendBird to detect if the
Application
is in background automatically.SendBird by default tracks the
Application
state by being notifiedActivity#onResume() and Activity#onPause() event in theApplication
.This enables connection is automatically made or closed whenApplication
goes foreground or background respectively.This auto-detection rendersApplication
can receive push notifications (FCM) without calling disconnect explicitly.You can be notified when yourApplication
goes foreground and connection is reestablished with onReconnectSucceeded callback (refer to ConnectionHandler and addConnectionHandler).If you want theApplication
not to act like in background so connection to still open,for instance when you start external galleryActivity
to send photos from youApplication
,set this as false with such as startActivityForResult call and then set true again at Activity#onResume().- Parameters:
enable
- If true, automaticApplication
state tracking is on.
-
getAutoBackgroundDetection
static boolean getAutoBackgroundDetection()
Gets SendBird auto background detection status. For details, refer to setAutoBackgroundDetection.
-
setNetworkAwarenessReconnection
static void setNetworkAwarenessReconnection(boolean enable)
Sets SendBird to reconnect automatically by network awareness.
- Parameters:
enable
- If true, the reconnection by network awareness is on.
-
getNetworkAwarenessReconnection
static boolean getNetworkAwarenessReconnection()
Gets SendBird network awareness reconnection status. For details, refer to setNetworkAwarenessReconnection.
-
getConnectionState
static SendBird.ConnectionState getConnectionState()
Gets SDK connection state.
-
connect
static void connect(String userId, SendBird.ConnectHandler handler)
Connects to SendBird with given
User
ID.If you have createdUser
s with access token,refer to connect.Even thoughUser
is not created by Platform API, this method creates one and calls callback to return it.- Parameters:
userId
-User
ID to connect with.handler
- Callback handler.
-
connect
static void connect(String userId, String accessToken, SendBird.ConnectHandler handler)
Connects to SendBird with given
User
ID and access token.If you have createdUser
s without access token,refer to connect or just pass access token withnull
.- Parameters:
userId
-User
ID to connect with.accessToken
- Access token.handler
- Callback handler.
-
connect
static void connect(String userId, String accessToken, String apiHost, String wsHost, SendBird.ConnectHandler handler)
Connects to SendBird with given
User
ID and access token.If you have createdUser
s without access token,refer to connect or just pass access token withnull
.- Parameters:
userId
-User
ID to connect with.accessToken
- Access token.apiHost
- Custom API Host.wsHost
- Custom WS Host.handler
- Callback handler.
-
reconnect
static boolean reconnect()
Tries reconnection with previously and successfully connected user information. This can be called in onReconnectFailed or where you check the device network statusto let the SDK try reconnection. onReconnectStarted will be called after you callthis (note that it will not be called if there is previously started connection process which has not finished),and onReconnectFailed or onReconnectSucceeded will becalled according to the connection status afterwards.Usually, the SDK automatically retries connection process when the networkconnection is lost with some backoff period. When you call this method, you can start connection processimmediately.
-
addChannelHandler
static void addChannelHandler(String identifier, SendBird.ChannelHandler handler)
Adds a channel handler. All added handlers will be notified when events occur.
- Parameters:
identifier
- ID of handler to be added.handler
- Handler to be added.
-
removeChannelHandler
static SendBird.ChannelHandler removeChannelHandler(String identifier)
Removes a channel handler. The deleted handler no longer be notified.
- Parameters:
identifier
- ID of handler to be removed.
-
removeAllChannelHandlers
static void removeAllChannelHandlers()
Removes all channel handlers added by addChannelHandler.
-
addUserEventHandler
static void addUserEventHandler(String identifier, SendBird.UserEventHandler handler)
Adds a user event handler. All added handlers will be notified when events occur.
- Parameters:
identifier
- ID of handler to be added.handler
- Handler to be added.
-
removeUserEventHandler
static SendBird.UserEventHandler removeUserEventHandler(String identifier)
Removes a user event handler. The deleted handler no longer be notified.
- Parameters:
identifier
- ID of handler to be removed.
-
removeAllUserEventHandlers
static void removeAllUserEventHandlers()
Removes all user event handlers added by addUserEventHandler.
-
addConnectionHandler
static void addConnectionHandler(String identifier, SendBird.ConnectionHandler handler)
Adds a connection handler. All added handlers will be notified when events occurs.
- Parameters:
identifier
- ID of handler to be added.handler
- Handler to be added.
-
removeConnectionHandler
static SendBird.ConnectionHandler removeConnectionHandler(String identifier)
Removes a connection handler. The deleted handler no longer be notified.
- Parameters:
identifier
- ID of handler to be removed.
-
removeAllConnectionHandlers
static void removeAllConnectionHandlers()
Removes all connection handlers added by addConnectionHandler.
-
disconnect
static void disconnect(SendBird.DisconnectHandler handler)
Disconnects from SendBird.
- Parameters:
handler
- Callback handler.
-
getAppInfo
static AppInfo getAppInfo()
Returns obtain information on the set application settings.
-
getCurrentUser
static User getCurrentUser()
Gets the current
User
.
-
getLastConnectedAt
static long getLastConnectedAt()
Gets the last connected timestamp.
-
createUserListQuery
@Deprecated() static UserListQuery createUserListQuery()
Creates a query instance to get the whole
User
list.
-
createUserListQuery
@Deprecated() static UserListQuery createUserListQuery(List<String> userIds)
Creates a query instance to get the filtered
User
list byUser
IDs.- Parameters:
userIds
-User
IDs to query.
-
createApplicationUserListQuery
static ApplicationUserListQuery createApplicationUserListQuery()
Creates a query instance to get the whole
User
list.
-
createBlockedUserListQuery
static BlockedUserListQuery createBlockedUserListQuery()
Creates a query instance to get only the blocked
User
(by me) list.
-
updateCurrentUserInfoWithProfileImage
static void updateCurrentUserInfoWithProfileImage(String nickname, File profileImage, SendBird.UserInfoUpdateHandler handler)
Updates current
User
's information.- Parameters:
nickname
- Nickname to be used.profileImage
- Image file to be used.handler
- Callback handler.
-
updateCurrentUserInfo
static void updateCurrentUserInfo(String nickname, String profileUrl, SendBird.UserInfoUpdateHandler handler)
Updates current
User
's information.- Parameters:
nickname
- Nickname to be used.profileUrl
- Image URL to be used.handler
- Callback handler.
-
updateCurrentUserInfo
static void updateCurrentUserInfo(List<String> preferredLanguages, SendBird.UserInfoUpdateHandler handler)
Updates current
User
's information.- Parameters:
preferredLanguages
- Preferred languages for push translation.handler
- Callback handler.
-
getPendingPushToken
static String getPendingPushToken()
Gets the pending push token.
-
registerPushTokenForCurrentUser
@Deprecated() static void registerPushTokenForCurrentUser(String gcmRegToken, SendBird.RegisterPushTokenHandler handler)
Registers push token for the current
User
to receive push notification.To enable push notification and get a token, refer to SendBird Docs.- Parameters:
gcmRegToken
- GCM push token.handler
- Callback handler.
-
registerPushTokenForCurrentUser
static void registerPushTokenForCurrentUser(String gcmRegToken, SendBird.RegisterPushTokenWithStatusHandler handler)
Registers push token for the current
User
to receive push notification.To enable push notification and get a token, refer to SendBird Docs.Push token registration succeeds only when the connection (connect, connect) is made.Otherwise, callback will return with PENDING status. Then, you can register push token again by callingSendBird.registerPushTokenForCurrentUser(SendBird.getPendingPushToken(), RegisterPushTokenWithStatusHandler)
after the connection is done.This just adds token to the server. If you want to register this token and delete all the previous ones, refer to registerPushTokenForCurrentUser.- Parameters:
gcmRegToken
- GCM push token.handler
- Callback handler.
-
registerPushTokenForCurrentUser
static void registerPushTokenForCurrentUser(String gcmRegToken, boolean unique, SendBird.RegisterPushTokenWithStatusHandler handler)
Registers push token for the current
User
to receive push notification.To enable push notification and get a token, refer to SendBird Docs.Push token registration succeeds only when the connection (connect, connect) is made.Otherwise, callback will return with PENDING status. Then, you can register push token again by callingSendBird.registerPushTokenForCurrentUser(SendBird.getPendingPushToken(), unique, RegisterPushTokenWithStatusHandler)
after the connection is done.- Parameters:
gcmRegToken
- GCM push token.unique
- If true, all the previously registered token for the currentUser
will be deleted and this token will be the unique one.handler
- Callback handler.
-
unregisterPushTokenForCurrentUser
static void unregisterPushTokenForCurrentUser(String gcmRegToken, SendBird.UnregisterPushTokenHandler handler)
Unregisters push token for the current
User
.- Parameters:
gcmRegToken
- GCM push token.handler
- Callback handler.
-
unregisterPushTokenAllForCurrentUser
static void unregisterPushTokenAllForCurrentUser(SendBird.UnregisterPushTokenHandler handler)
Unregisters all push token bound to the current
User
.- Parameters:
handler
- Callback handler.
-
getMyPushTokensByToken
static void getMyPushTokensByToken(String token, SendBird.PushTokenType type, SendBird.GetPushTokensHandler handler)
Requests push tokens of current user from given token.The result is passed to
handler
.- Parameters:
token
- Token to get next push tokens.type
- PushTokenType.handler
- Callback handler.
-
setDoNotDisturb
static void setDoNotDisturb(boolean doNotDisturbOn, int startHour, int startMin, int endHour, int endMin, String timezone, SendBird.SetDoNotDisturbHandler handler)
Sets Do-not-disturb option for the current
User
.If this option is enabled, the currentUser
does not receive push notification during the specified time repeatedly.If you want to snooze specific period, use setSnoozePeriod.- Parameters:
doNotDisturbOn
- Enables option or not.startHour
- Start hour (0~23).startMin
- Start minute (0~59).endHour
- End hour (0~23).endMin
- End minute (0~59).timezone
- Timezone.handler
- Callback handler.
-
getDoNotDisturb
static void getDoNotDisturb(SendBird.GetDoNotDisturbHandler handler)
Gets Do-not-disturb option for the current
User
.- Parameters:
handler
- Callback handler.
-
setSnoozePeriod
static void setSnoozePeriod(boolean snoozeOn, long startTs, long endTs, SendBird.SetSnoozePeriodHandler handler)
Sets snooze period for the current
User
.If this option is enabled, the currentUser
does not receive push notification during the given period. It's not a repetitive operation.If you want to snooze repeatedly, use setDoNotDisturb.- Parameters:
snoozeOn
- Enables option or not.startTs
- Start timestamp of snooze periodendTs
- End timestamp of snooze periodhandler
- Callback handler.
-
getSnoozePeriod
static void getSnoozePeriod(SendBird.GetSnoozePeriodHandler handler)
Gets snooze period for the current
User
.- Parameters:
handler
- Callback handler.
-
setPushSound
static void setPushSound(String sound, SendBird.SetPushSoundHandler handler)
Sets the push notification sound file path for the current
User
.This setting will be delivered on push notification payload.- Parameters:
sound
- Sound file path.handler
- Callback handler.
-
getPushSound
static void getPushSound(SendBird.GetPushSoundHandler handler)
Gets push notification sound path for the current
User
.- Parameters:
handler
- Callback handler.
-
setPushTemplate
static void setPushTemplate(String templateName, SendBird.SetPushTemplateHandler handler)
Sets push template option for the current
User
. The only valid arguments for template name are PUSH_TEMPLATE_DEFAULT and PUSH_TEMPLATE_ALTERNATIVE.If PUSH_TEMPLATE_DEFAULT is set, the push notification will contain the original message in themessage
field of the push notification.If PUSH_TEMPLATE_ALTERNATIVE is set,message
of push notification will be replaced by the content you've set onSendBird Dashboard.- Parameters:
templateName
- Name of template to be applied to currentUser
.handler
- Callback handler.
-
getPushTemplate
static void getPushTemplate(SendBird.GetPushTemplateHandler handler)
Gets push template option for the current
User
. For details of push template option, refer to setPushTemplate.This can be used, for instance, when you need to check the push notification content preview is on or off at the moment.- Parameters:
handler
- Callback handler.
-
setPushTriggerOption
static void setPushTriggerOption(SendBird.PushTriggerOption pushTriggerOption, SendBird.SetPushTriggerOptionHandler handler)
Sets the current
User
's push trigger option.If certain channel's push trigger option is set to DEFAULT, it works according to the state of PushTriggerOption.If not, push messages will be triggered according to the state of com.sendbird.android.GroupChannel.PushTriggerOption.Refer to com.sendbird.android.GroupChannel.PushTriggerOption.- Parameters:
pushTriggerOption
-PushTriggerOption
.handler
- Callback handler.
-
getPushTriggerOption
static void getPushTriggerOption(SendBird.GetPushTriggerOptionHandler handler)
Gets the current
User
's push trigger option. Refer to PushTriggerOption.For details of push trigger option, refer to setPushTriggerOption.- Parameters:
handler
- Callback handler.
-
setChannelInvitationPreference
static void setChannelInvitationPreference(boolean autoAccept, SendBird.SetChannelInvitationPreferenceHandler handler)
Sets the current
User
's preference forGroupChannel
join.If this is set astrue
, theUser
will automatically join theGroupChannel
.If set asfalse
, theUser
can join theGroupChannel
by calling acceptInvitation or decline the invitation by calling declineInvitation.- Parameters:
autoAccept
-GroupChannel
invitation auto-acceptance preference.handler
- Callback handler.
-
getChannelInvitationPreference
static void getChannelInvitationPreference(SendBird.GetChannelInvitationPreferenceHandler handler)
Gets the current
User
's preference forGroupChannel
join.If this is set astrue
, theUser
will automatically join theGroupChannel
.If set asfalse
, theUser
can join theGroupChannel
by calling acceptInvitation or decline the invitation by calling declineInvitation.- Parameters:
handler
- Callback handler.
-
blockUser
static void blockUser(User userToBlock, SendBird.UserBlockHandler handler)
Blocks the specified
User
.BlockedUser
cannot send messages to the blocker.- Parameters:
userToBlock
-User
to block.handler
- Callback handler.
-
blockUserWithUserId
static void blockUserWithUserId(String userIdToBlock, SendBird.UserBlockHandler handler)
Blocks the specified
User
ID.BlockedUser
cannot send messages to the blocker.- Parameters:
userIdToBlock
-User
ID to block.handler
- Callback handler.
-
unblockUser
static void unblockUser(User blockedUser, SendBird.UserUnblockHandler handler)
Unblocks the specified
User
.UnblockedUser
can send messages to the ex-blocker.- Parameters:
blockedUser
-User
to unblock.handler
- Callback handler.
-
unblockUserWithUserId
static void unblockUserWithUserId(String blockedUserId, SendBird.UserUnblockHandler handler)
Unblocks the specified
User
ID.UnblockedUser
cannot send messages to the ex-blocker.- Parameters:
blockedUserId
-User
ID to unblock.handler
- Callback handler.
-
addFriends
static void addFriends(List<String> userIds, SendBird.AddFriendsHandler handler)
Add friends.
- Parameters:
userIds
-User
IDs to add friends.handler
- Callback handler.
-
deleteFriends
static void deleteFriends(List<String> userIds, SendBird.DeleteFriendsHandler handler)
Delete friends.
- Parameters:
userIds
-User
IDs to delete friends.handler
- Callback handler.
-
deleteFriend
static void deleteFriend(String userId, SendBird.DeleteFriendHandler handler)
Delete friend.
- Parameters:
userId
-User
ID to delete friend.handler
- Callback handler.
-
uploadFriendDiscoveries
static void uploadFriendDiscoveries(Map<String, String> discoveryMap, SendBird.UploadFriendDiscoveriesHandler handler)
Upload friend discoveries. addUserEventHandlerremoveUserEventHandlerremoveAllUserEventHandlersonFriendsDiscovered
- Parameters:
discoveryMap
- The discovery key, friend name map to upload friend discoveries.handler
- Callback handler.
-
deleteFriendDiscoveries
static void deleteFriendDiscoveries(List<String> discoveryKeys, SendBird.DeleteFriendDiscoveriesHandler handler)
Delete friend discoveries.
- Parameters:
discoveryKeys
- The discovery keys to delete friend discoveries.handler
- Callback handler.
-
deleteFriendDiscovery
static void deleteFriendDiscovery(String discoveryKey, SendBird.DeleteFriendDiscoveryHandler handler)
Delete friend discovery.
- Parameters:
discoveryKey
- The discovery key to delete friend discovery.handler
- Callback handler.
-
getFriendChangeLogsByToken
static void getFriendChangeLogsByToken(String token, SendBird.GetFriendChangeLogsByTokenHandler handler)
Get friend changelogs by token.
- Parameters:
token
- Token to get next friend changelogs.handler
- Callback handler.
-
createFriendListQuery
static FriendListQuery createFriendListQuery()
Creates a query instance to get friends.
-
getMyGroupChannelChangeLogsByToken
@Deprecated() static void getMyGroupChannelChangeLogsByToken(String token, List<String> customTypes, SendBird.GetMyGroupChannelChangeLogsHandler handler)
Requests the channel changelogs from given token.The result is passed to
handler
.- Parameters:
token
- Token to get next channel changelogs.customTypes
-GroupChannel
custom types filter.handler
- Callback handler.
-
getMyGroupChannelChangeLogsByTimestamp
@Deprecated() static void getMyGroupChannelChangeLogsByTimestamp(long ts, List<String> customTypes, SendBird.GetMyGroupChannelChangeLogsHandler handler)
Requests the channel changelogs after given timestamp.The result is passed to
handler
.- Parameters:
ts
- Timestamp to load changelogs.customTypes
-GroupChannel
custom types filter.handler
- Callback handler.
-
getMyGroupChannelChangeLogsByToken
@Deprecated() static void getMyGroupChannelChangeLogsByToken(String token, List<String> customTypes, boolean includeEmpty, SendBird.GetMyGroupChannelChangeLogsHandler handler)
Requests the channel changelogs from given token.The result is passed to
handler
.- Parameters:
token
- Token to get next channel changelogs.customTypes
-GroupChannel
custom types filter.includeEmpty
- Flag to include empty channels.handler
- Callback handler.
-
getMyGroupChannelChangeLogsByTimestamp
@Deprecated() static void getMyGroupChannelChangeLogsByTimestamp(long ts, List<String> customTypes, boolean includeEmpty, SendBird.GetMyGroupChannelChangeLogsHandler handler)
Requests the channel changelogs after given timestamp.The result is passed to
handler
.- Parameters:
ts
- Timestamp to load changelogs.customTypes
-GroupChannel
custom types filter.includeEmpty
- Flag to include empty channels.handler
- Callback handler.
-
getMyGroupChannelChangeLogsByTokenWithParams
static void getMyGroupChannelChangeLogsByTokenWithParams(String token, GroupChannelChangeLogsParams params, SendBird.GetMyGroupChannelChangeLogsHandler handler)
Requests the channel changelogs from given token.The result is passed to
handler
.- Parameters:
token
- Token to get next channel changelogs.params
- Params for getting group channel list.handler
- Callback handler.
-
getMyGroupChannelChangeLogsByTimestampWithParams
static void getMyGroupChannelChangeLogsByTimestampWithParams(long ts, GroupChannelChangeLogsParams params, SendBird.GetMyGroupChannelChangeLogsHandler handler)
Requests the channel changelogs after given timestamp.The result is passed to
handler
.- Parameters:
ts
- Timestamp to load changelogs.params
- Params for getting group channel list.handler
- Callback handler.
-
markAsDelivered
@Deprecated() static void markAsDelivered(String channelUrl)
Sends mark as delivered to this channel when you received push message from us.
- Parameters:
channelUrl
- target channel's url
-
markAsDelivered
static void markAsDelivered(Map<String, String> data)
Sends mark as delivered to this channel when you received push message from us.
- Parameters:
data
- The payload data from the push.
-
markAsReadAll
static void markAsReadAll(SendBird.MarkAsReadHandler handler)
Sends mark as read to all joined
GroupChannel
s.This method has rate limit. You can send one request per second.It returns SendBirdException if you exceed the rate limit.- Parameters:
handler
- Callback handler.
-
markAsReadWithChannelUrls
static void markAsReadWithChannelUrls(List<String> channelUrls, SendBird.MarkAsReadHandler handler)
Sends mark as read to joined
GroupChannel
s.This method has rate limit. You can send one request per second.It returns SendBirdException if you exceed the rate limit.- Parameters:
channelUrls
- Channel Urls.handler
- Callback handler.
-
getAllEmoji
static void getAllEmoji(SendBird.GetAllEmojiHandler handler)
Requests the all emoji.The result is passed to
handler
.- Parameters:
handler
- Callback handler.
-
getEmojiCategory
static void getEmojiCategory(long emojiCategoryId, SendBird.GetEmojiCategoryHandler handler)
Requests the emoji category.The result is passed to
handler
.- Parameters:
emojiCategoryId
- Emoji category id.handler
- Callback handler.
-
getEmoji
static void getEmoji(String key, SendBird.GetEmojiHandler handler)
Requests the emoji.The result is passed to
handler
.- Parameters:
key
- Emoji key.handler
- Callback handler.
-
getTotalUnreadMessageCount
static void getTotalUnreadMessageCount(GroupChannel.GroupChannelTotalUnreadMessageCountHandler handler)
Gets the total number of unread message of all
GroupChannel
s the current user has joined.- Parameters:
handler
- Callback handler.
-
getTotalUnreadMessageCount
static void getTotalUnreadMessageCount(List<String> channelCustomTypes, GroupChannel.GroupChannelTotalUnreadMessageCountHandler handler)
Gets the total number of unread message of
GroupChannel
s with channel custom types filter.- Parameters:
channelCustomTypes
-GroupChannel
custom type list.handler
- Callback handler.
-
getTotalUnreadMessageCount
static void getTotalUnreadMessageCount(GroupChannelTotalUnreadMessageCountParams params, GroupChannel.GroupChannelTotalUnreadMessageCountHandler handler)
Gets the total number of unread message of
GroupChannel
s withGroupChannelTotalUnreadMessageCountParams
filter.- Parameters:
params
-GroupChannelTotalUnreadMessageCountParams
handler
- Callback handler.
-
getSubscribedTotalUnreadMessageCount
static int getSubscribedTotalUnreadMessageCount()
Gets the subscribed total number of unread message of all
GroupChannel
s the current user has joined.
-
getSubscribedCustomTypeTotalUnreadMessageCount
static int getSubscribedCustomTypeTotalUnreadMessageCount()
Gets the total number of unread message of
GroupChannel
s with subscribed custom types.
-
getSubscribedCustomTypeUnreadMessageCount
static int getSubscribedCustomTypeUnreadMessageCount(String customType)
Gets the number of unread message of
GroupChannel
with subscribed custom type.- Parameters:
customType
- The subscribed custom type.
-
getUnreadItemCount
static void getUnreadItemCount(Collection<GroupChannel.UnreadItemKey> keys, GroupChannel.GroupChannelGetUnreadItemCountHandler handler)
Gets the unread item count of
GroupChannel
s from keys.- Parameters:
keys
- Unread item keys.handler
- Callback handler.
-
getTotalUnreadChannelCount
static void getTotalUnreadChannelCount(GroupChannel.GroupChannelTotalUnreadChannelCountHandler handler)
Gets the total number of unread
GroupChannel
s the current user has joined.- Parameters:
handler
- Callback handler.
-
getTotalUnreadChannelCount
static void getTotalUnreadChannelCount(GroupChannelTotalUnreadChannelCountParams params, GroupChannel.GroupChannelTotalUnreadChannelCountHandler handler)
Gets the total number of unread
GroupChannel
s the current user has joined.- Parameters:
params
- GroupChannelTotalUnreadChannelCountParams.handler
- Callback handler.
-
getGroupChannelCount
static void getGroupChannelCount(GroupChannelListQuery.MemberStateFilter memberStateFilter, GroupChannel.GroupChannelChannelCountHandler handler)
Gets the number of my
GroupChannel
s.- Parameters:
memberStateFilter
- GroupChannelListQuery.MemberStateFilter.handler
- Callback handler.
-
allowFriendDiscovery
static void allowFriendDiscovery(boolean allow, AllowFriendDiscoveryHandler handler)
Sets friend discoverability of current user.
- Parameters:
allow
- true to allow, false to disallow.handler
- a completion handler to get notified of complete event.
-
getAllowFriendDiscovery
static void getAllowFriendDiscovery(GetAllowFriendDiscoveryHandler handler)
Gets friend discoverability of current user.
- Parameters:
handler
- A handler to get notified of the result.
-
-
-
-