This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
implementation 'com.sendbird.sdk:sendbird-android-sdk:3.0.141' | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Sender Side | |
// To listen to an update from all the other channel members' client apps, implement the 'onReadReceiptUpdated()' with things to do when notified. | |
SendBird.addChannelHandler(UNIQUE_HANDLER_ID, new SendBird.ChannelHandler() { | |
@Override | |
public void onReadReceiptUpdated(GroupChannel groupChannel) { | |
if (currentGroupChannel.getUrl().equals(groupChannel.getUrl())) { | |
// For example, code for redrawing a channel view. | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Receiver Side | |
// Call the 'markAsRead()' when the current user views unread messages in a group channel. | |
groupChannel.markAsRead(); | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Receiver Side | |
// Call the 'markAsRead()' when the current user views unread messages in a group channel. | |
groupChannel.markAsRead(); | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Sender’s side | |
SendBird.addChannelHandler(UNIQUE_HANDLER_ID, new SendBird.ChannelHandler() { | |
@Override | |
public void onMessageReceived(BaseChannel baseChannel, BaseMessage baseMessage) { | |
} | |
@Override | |
public void onDeliveryReceiptUpdated(GroupChannel channel) { | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Receiver Side | |
public class FirebaseMessagingServiceEx extends FirebaseMessagingService { | |
@Override | |
public void onMessageReceived(RemoteMessage remoteMessage) { | |
try { | |
JSONObject sendBird = new JSONObject(remoteMessage.getData().get("sendbird")); | |
JSONObject channel = (JSONObject) sendBird.get("channel"); | |
String channelUrl = (String) channel.get("channel_url"); | |
//Mark the Message as Delivered |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SendBirdSyncManager.Options options = new SendBirdSyncManager.Options.Builder() | |
.setMessageResendPolicy(SendBirdSyncManager.MessageResendPolicy.AUTOMATIC) | |
.setAutomaticMessageResendRetryCount(5) | |
.build(); | |
SendBirdSyncManager.setup(context, userId, options, handler); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onResume() { | |
super.onResume(); | |
SendBird.addConnectionHandler(YOUR_CONNECTION_HANDLER_ID, new SendBird.ConnectionHandler() { | |
@Override | |
public void onReconnectStarted() { | |
SendBirdSyncManager.getInstance().pauseSync(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onFailedMessageEvent(MessageCollection collection, final List<BaseMessage> messages, final MessageEventAction action, final FailedMessageEventActionReason reason) { | |
if (getActivity() == null) { | |
return; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Sender Side | |
groupChannel.startTyping(); //Sender Side | |
groupChannel.endTyping(); | |
... | |
//Receiver side | |
// To listen to an update from all the other channel members' client apps, implement the 'onTypingStatusUpdated()' with things to do when notified. | |
SendBird.addChannelHandler(UNIQUE_HANDLER_ID, new SendBird.ChannelHandler() { | |
@Override | |
public void onTypingStatusUpdated(GroupChannel groupChannel) { | |
if (currentGroupChannel.getUrl().equals(groupChannel.getUrl())) { |
NewerOlder