Quick Start

1. Creating a SendBird Application

The first thing you need to do is to log in to the SendBird Dashboard and create a SendBird application. If you do not yet have an account, you can log in with Google, GitHub, or create a new account.

You should create one application per service, regardless of the platform. For example, an app released in both Android and iOS would require only one application to be created in the Dashboard.

All users within the same SendBird application are able to communicate with each other, across all platforms. This means users using iOS, Android, web clients, etc. can all chat with one another. However, users in different SendBird applications cannot talk to each other.

2. Requirements

SendBird .NET SDK is designed and tested on Mono/.NET 2.0 platform and Xamarin Studio 6.1.1. You can also use our SDK on any platforms which are compatible with Mono/.NET 2.0.

3. Download Latest .NET SDK

WebSocket Library

SendBird .NET SDK uses websocket-sharp for websocket connection. You must include websocket-sharp.dll as well as SendBird.dll or SendBird.Unity.dll.

You can find websocket-sharp.dll on the same repository of SendBird .NET SDK. Repository

Authentication

Initializing with APP_ID

Please initialize SendBird using the APP_ID assigned for your SendBird application before trying to login SendBird.
You could initialize it typically in your user login screen.

SendBirdClient.Init(APP_ID);

Connecting with UserID

SendBird requires only UserID to login in Client SDK by default.
It creates a user account on demand if UserID has not been taken yet.
UserID could be any unique string id such as email, uid in your database.

This simple authentication is useful when you are in development or your service doesn't need additional security.

SendBirdClient.Connect(USER_ID, (User user, SendBirdException e) =>
{
    if(e != null)
    {
        // Error
        return;
    }
});

Connecting with UserID and Access Token

With SendBird Platform API, you can create a user with an access token or issue an access token for an existing user. Once the access token is issued for the user, you should provide the correct access token in login method.

Create a SendBird user account via Platform API when your user signs up your service.
Save the access token to your secured persistent store.
Load the access token in your client and pass it to SendBird login method.
Issue a new access token via Platform API and update it in your persistent store periodically.

  • You can change Non Access Token User Policy on your dashboard settings.
SendBirdClient.Connect(USER_ID, ACCESS_TOKEN, (User user, SendBirdException e) =>
{
    if(e != null)
    {
        // Error
        return;
    }
});

Updating User Profile

You can update users information after connected to SendBird.

SendBirdClient.Connect(USER_ID, (User user, SendBirdException e) =>
{
    if(e != null)
    {
        // Error
        return;
    }

    SendBirdClient.UpdateCurrentUserInfo(NICKNAME, PROFILE_URL, (SendBirdException e1) =>
    {
        if(e1 != null)
        {
            // Error
            return;
        }
    });
});

Updating User Profile with Profile Image Upload

You can update users information and uploading profile image to SendBird.

SendBirdClient.Connect(USER_ID, (User user, SendBirdException e) =>
{
    if(e != null)
    {
        // Error
        return;
    }

    SendBirdClient.UpdateCurrentUserInfoWithProfileImage(NICKNAME, FILE_PATH, (SendBirdException e1) =>
    {
        if(e1 != null)
        {
            // Error
            return;
        }
    });
});

Channel Type

There are some terms you should understand before starting this tutorial.

Open Channel

Open channel is a public chat. This is a channel type which anyone can participate without a permission. It can handle thousands of users in one channel. ex) Twitch-style public chat

Group Channel

Group channel is a private chat. The user who wants to join the group channel has to be invited by other user who is already joined the group channel.

  • Distinct Property : Distinct property enabled group channel is always reused for same channel members. If a new member gets invited or the member left from the channel, then the distinct property disabled automatically.
    If you don't set distinct property on the channel, it always create new channel for the same members.

  • 1-on-1 messaging : 1-on-1 messaging is a private channel between two users. You can enable distinct property for the channel to get always same channel for the same users. ex) Twitter-style Direct Message

  • Group messaging : Group messaging is a private channel among multiple users. You can invite up to hundreds of members into the group channel. ex) Whatsapp-style closed group chat

Type Open Channel Group Channel
Access Control Public Invitation required
Class Name OpenChannel GroupChannel
Number of Members Over a few thousands Less than a few hundreds
How to create SendBird Dashboard / Platform API / Client SDK Client SDK / Platform API
Operators Supported N/A
User Ban Supported N/A
User Mute Supported N/A
Freeze Channel Supported N/A
Push notifications N/A Supported
Unread counts N/A Supported
Read receipts N/A Supported
Typing indicators N/A Supported

Open Channel

Open channel is a public chat. This is a channel type which anyone can participate without a permission. It can handle thousands of users in one channel. ex) Twitch-style public chat

Creating an Open Channel

You can create an Open Channel in SendBird Dashboard.
You should set "Channel Topic", a name of the channel and "Channel URL", a unique identifier of the channel. This is useful when you have a small and static number of channels such as "Lobby Chat" in games.

create_channel_dashboard

You can also create your channels via SendBird Platform API.
You should use it when your channels need to be created on demand or dynamically.

OpenChannel.CreateChannel(NAME, COVER_URL, DATA, (OpenChannel openChannel, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

Getting a list of Open Channels

You can get a list of Open Channels with OpenChannel class.
It returns a list of OpenChannel objects.

  • You must be connected to SendBird before requesting Open channel list.
OpenChannelListQuery mChannelListQuery = OpenChannel.CreateOpenChannelListQuery();
mChannelListQuery.Next((List<OpenChannel> channels, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

Entering an Open Channel

You must enter open channels to receive messages from the channels.

You can enter open channels up to 10 channels at once.

Entered open channels are valid only within current connection. You must re-enter the channels if you disconnect and connect to SendBird.

OpenChannel.GetChannel(CHANNEL_URL, (OpenChannel openChannel, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }

    openChannel.Enter((SendBirdException e) => {
        if (e != null) {
            // Error.
            return;
        }
    });
});

Exiting from an Open Channel

To stop getting messages from open channels, you should exit from the channels.

OpenChannel.GetChannel(CHANNEL_URL, (OpenChannel openChannel, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }

    openChannel.Exit((SendBirdException e) => {
        if (e != null) {
            // Error.
            return;
        }
    });
});

Loading Previous Messages

Before entering to the channel, getting previous messages in the channel is typically needed to render previous messages in chat UI.

PreviousMessageListQuery mPrevMessageListQuery = openChannel.CreatePreviousMessageListQuery();
mPrevMessageListQuery.Load(30, true, (List<BaseMessage> messages, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

Sending Messages

After entering to a channel, a user can send various types of messages.
When you send text messages, you can also attach arbitrary strings via data field.
You can utilize this field to send some structured data such as a font size, a font type, or custom object json.

When some deliveries fail due to network issues, it will returns an exception for the message. In UI, you could display only messages appeared as 'sent' only if sending message is succeeded.

openChannel.SendUserMessage(MESSAGE, DATA, (UserMessage userMessage, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

A user can also send any binary files to SendBird.

Note that if you upload your file directly, a size limit is imposed per file. This limit depends on your plan, and can be viewed from your Dashboard.

To send meta data with a file, you can use custom data.

openChannel.SendFileMessage(FILE_PATH, FILE_NAME, FILE_TYPE, FILE_SIZE, CUSTOM_DATA, (FileMessage fileMessage, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

Receiving Messages

After entering to a channel, all messages can be received by adding ChannelHandler.
You can cast a BaseMessage object among three types of messages.

  • UserMessage: User text message.
  • FileMessage: User binary message.
  • AdminMessage: Admin message which could be sent via Platform API by admin.

UNIQUE_HANDLER_ID is an identifier for multiple channel handlers registration.

SendBirdClient.ChannelHandler ch = new SendBirdClient.ChannelHandler();
ch.OnMessageReceived = (BaseChannel baseChannel, BaseMessage baseMessage) => {
};
SendBirdClient.AddChannelHandler(UNIQUE_HANDLER_ID, ch);

Loading Messages by Timestamp

When a user scrolls up a screen to see previous messages, you can query previous messages starting from the timestamp of the earliest message.

Note that the number of messages could be larger than the limit you set when there are messages having same timestamps on edge.

MessageListQuery mMessageListQuery = openChannel.CreateMessageListQuery();
mMessageListQuery.Prev(EARLIEST_MESSAGE_TIMESTAMP, LIMIT, REVERSE_ORDER, (List<BaseMessage> list, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

Getting a list of Participants in a Channel

Participants are online users who are currently receiving all messages from the open channel.

UserListQuery mQuery = openChannel.CreateParticipantListQuery();
mQuery.Next((List<User> list, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

Getting a list of Banned or Muted Users in a Channel

You can also create a query to get a list of muted or banned users in an open channel.

This query is only available for users who are registered as operators of the open channel.

UserListQuery mQuery = openChannel.CreateBannedUserListQuery(); //or CreateMutedUserListQuery()
mQuery.Next((List<User> list, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

Deleting Messages

User can delete a message. It gives an error if the user try to delete messages which are sent by others.
Channel operators can delete any messages on the channel.
It also fires a message deleted events to other users on the channel.

channel.DeleteMessage(BASE_MESSAGE, (SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

You can receive a MessageDeleted event in the channel handler.

SendBirdClient.ChannelHandler ch = new SendBirdClient.ChannelHandler();
ch.OnMessageDeleted = (BaseChannel baseChannel, long messageId) => {
};
SendBirdClient.AddChannelHandler(UNIQUE_HANDLER_ID, ch);

Group Channel

Group channel is a private chat. The user who wants to join the group channel has to be invited by another user who is already joined the channel.

  • User will automatically receive all messages from the group channels where the user belongs.

Creating Group Channels

Group channel is created in client SDK on demand.

Distinct Property : Distinct property enabled group channel is always reused for same channel members. If a new member gets invited or the member left from the channel, then the distinct property disabled automatically.
If you don't set distinct property on the channel, it always create new channel for the same members.

GroupChannel.CreateChannelWithUserIds(userIds, false, (GroupChannel groupChannel, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

You can also create your channels via SendBird Platform API.
You should use it when you want to control channel creations and member invitations in server side.

Inviting Users to an existing Channel

Only members on the channel will be able to invite other users to the channel.

groupChannel.InviteWithUserIds(userIds, (SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

Leaving a Group Channel

After leaving from a channel, you are no longer a member of the channel so you won't receive any messages from the channel.

groupChannel.Leave((SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

Getting a list of My Group Channels

You can get a list of Group Channels with GroupChannel.CreateMyGroupChannelListQuery.
It returns a list of GroupChannel objects. You can also set an option to include empty channels.

GroupChannelListQuery mQuery = GroupChannel.CreateMyGroupChannelListQuery();
mQuery.SetIncludeEmpty(true);
mQuery.Next((List<GroupChannel> list, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

Sending Messages

After joining to a channel, a user can send various types of messages.
When you send text messages, you can also attach arbitrary strings via data field.
You can utilize this field to send some structured data such as a font size, a font type, or custom object json.

When some deliveries fail due to network issues, it will returns an exception for the message. In UI, you could display only messages appeared as 'sent' only if sending message is succeeded.

channel.SendUserMessage(MESSAGE, DATA, (UserMessage userMessage, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

A user can also send any binary files to SendBird.

Note that if you upload your file directly, a size limit is imposed per file. This limit depends on your plan, and can be viewed from your Dashboard.

To send meta data with a file, you can use custom data.

channel.SendFileMessage(FILE, FILE_NAME, FILE_TYPE, FILE_SIZE, CUSTOM_DATA, (FileMessage fileMessage, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

Receiving Messages

After entering to a channel, all messages can be received by adding ChannelHandler.
You can cast a BaseMessage object among three types of messages.

  • UserMessage: User text message.
  • FileMessage: User binary message.
  • AdminMessage: Admin message which could be sent via platform API by admin.

UNIQUE_HANDLER_ID is an identifier for multiple channel handlers registration.

SendBirdClient.ChannelHandler ch = new SendBirdClient.ChannelHandler();
ch.OnMessageReceived = (BaseChannel baseChannel, BaseMessage baseMessage) => {
    // Received a chat message.
};
SendBirdClient.AddChannelHandler(UNIQUE_HANDLER_ID, ch);

You should remove the channel handler where the UI is no longer valid.

SendBirdClient.RemoveChannelHandler(UNIQUE_HANDLER_ID);

Loading Previous Messages

Before entering to the channel, getting previous messages in the channel is typically needed to render previous messages in chat UI.

PreviousMessageListQuery mPrevMessageListQuery = groupChannel.CreatePreviousMessageListQuery();
mPrevMessageListQuery.Load(30, true, (List<BaseMessage> messages, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

Group Channel - Advance

Getting/Updating a list of all members

GroupChannel has members attributes and you can use it to get a list of members.
Members are automatically updated when you are online. If you disconnect from SendBird and connect it again, you should refresh the channel to update with latest information.

List<User> members = groupChannel.Members;

Typing Indicators

You can send typing events with StartTyping and EndTyping.

groupChannel.StartTyping();
groupChannel.EndTyping();

You can receive a TypingStatusUpdate event in the channel handler.

SendBirdClient.ChannelHandler ch = new SendBirdClient.ChannelHandler();
ch.OnTypingStatusUpdated = (GroupChannel groupChannel) => {
    if (currentGroupChannel.Url.Equals(groupChannel.Url)) {
        List<User> members = groupChannel.TypingMembers;
        // Refresh typing status.
    }
};
SendBirdClient.AddChannelHandler(UNIQUE_HANDLER_ID, ch);

Read Receipts

Users can send MarkAsRead events when users read messages.

groupChannel.MarkAsRead();

You can receive a ReadReceiptUpdate event in the channel handler.

SendBird.addChannelHandler(UNIQUE_HANDLER_ID, new SendBird.ChannelHandler() {
    @Override
});
SendBirdClient.ChannelHandler ch = new SendBirdClient.ChannelHandler();
ch.OnReadReceiptUpdated = (GroupChannel groupChannel) => {
    if (currentGroupChannel.Url.Equals(groupChannel.Url)) {
        foreach (BaseMessage msg in yourMessages) {
            int unreadCount = groupChannel.GetReadReceipt(msg);
            if (unreadCount <= 0) {
                // All members have read.
            } else {
                // Some members haven't read.
            }
        }
    }
};
SendBirdClient.AddChannelHandler(UNIQUE_HANDLER_ID, ch);

You can get updated receipt counts when you get ReadReceiptUpdate events

int unreadCount = mGroupChannel.GetReadReceipt(message);

Deleting Messages

A user can delete a message. It gives an error if the user tries to delete messages which are sent by others.
It also fires a message deleted events to other users on the channel.

channel.DeleteMessage(BASE_MESSAGE, (SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

You can receive a MessageDeleted event in the channel handler.

SendBirdClient.ChannelHandler ch = new SendBirdClient.ChannelHandler();
ch.OnMessageDeleted = (BaseChannel baseChannel, long messageId) => {
};
SendBirdClient.AddChannelHandler(UNIQUE_HANDLER_ID, ch);

Channel MetaData (beta)

You can save any key/value pair information into each channel with meta data.

If the value is integer and needs atomic increasing/decreasing operations, you should use meta counters instead.

With meta data/counters, you could save some additional information such as the number of likes, background colors, long description.

Meta Data

Create

Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("key1", "value1");
data.Add("key2", "value2");
channel.CreateMetaData(data, (Dictionary<string, string> map, SendBirdException e) =>
{
    if (e != null) {
        // Error.
        return;
    }
});

Update

Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("key1", "valueToUpdate");
data.Add("key2", "valueToUpdate");
channel.UpdateMetaData(data, (Dictionary<string, string> map, SendBirdException e) =>
{
    if (e != null) {
        // Error.
        return;
    }
});

Get

List<string> keys = new List<string>();
keys.Add("key1");
keys.Add("key2");
channel.GetMetaData(keys, (Dictionary<string, string> map, SendBirdException e) =>
{
    if (e != null) {
        // Error.
        return;
    }
});

Meta Counters

Create

Dictionary<string, int> counters = new Dictionary<string, int>();
counters.Add("key1", 1);
counters.Add("key2", 2);
channel.CreateMetaCounters(counters, (Dictionary<string, int> map, SendBirdException e) =>
{
    if (e != null) {
        // Error.
        return;
    }
});

Increase

Dictionary<string, int> counters = new Dictionary<string, int>();
counters.Add("key1", 2); // Increases by 2.
counters.Add("key2", 3); // Increases by 3.
channel.IncreaseMetaCounters(counters, (Dictionary<string, int> map, SendBirdException e) =>
{
    if (e != null) {
        // Error.
        return;
    }
});

Decrease

Dictionary<string, int> counters = new Dictionary<string, int>();
counters.Add("key1", 3); // Decreases by 3.
counters.Add("key2", 4); // Decreases by 4.
channel.DecreaseMetaCounters(counters, (Dictionary<string, int> map, SendBirdException e) =>
{
    if (e != null) {
        // Error.
        return;
    }
});

Get

List<string> keys = new List<string>();
keys.add("key1");
keys.add("key2");
channel.GetMetaCounters(keys, (Dictionary<string, int> map, SendBirdException e) =>
{
    if (e != null) {
        // Error.
        return;
    }
});

Event Handler

Channel Handler

You can register multiple channel handlers to receive various events and messages from SendBird.

Typically you should register the event handler in each activity.


SendBirdClient.ChannelHandler ch = new SendBirdClient.ChannelHandler();

ch.OnMessageReceived = (BaseChannel baseChannel, BaseMessage baseMessage) => {
    // Received a chat message.
};

ch.OnMessageDeleted = (BaseChannel baseChannel, long messageId) => {
  // When a message has been deleted.
};

ch.OnChannelChanged = (BaseChannel baseChannel) => {
  // When a channel property has been changed.
};

ch.OnChannelDeleted = (string channelUrl, BaseChannel.ChannelType channelType) => {
  // When a channel has been deleted.
};

ch.OnReadReceiptUpdated = (GroupChannel groupChannel) => {
    // When read receipt has been updated.
};

ch.OnTypingStatusUpdated = (GroupChannel groupChannel) => {
    // When typing status has been updated.
};

ch.OnUserJoined = (GroupChannel groupChannel, User user) => {
  // When a new member joined the group channel.
};

ch.OnUserLeft(GroupChannel groupChannel, User user) => {
  // When a member left the group channel.
};

ch.OnUserEntered = (OpenChannel openChannel, User user) => {
  // When a new user entered the open channel.
};

ch.OnUserExited = (OpenChannel openChannel, User user) => {
  // When a new user left the open channel.
};

ch.OnUserMuted = (OpenChannel openChannel, User user) => {
  // When a user is muted on the open channel.
};

ch.OnUserUnmuted = (OpenChannel openChannel, User user) => {
  // When a user is unmuted on the open channel.
};

ch.OnUserBanned = (OpenChannel openChannel, User user) => {
  // When a user is banned on the open channel.
};

ch.OnUserUnbanned = (OpenChannel openChannel, User user) => {
  // When a user is unbanned on the open channel.
};

ch.OnChannelFrozen(OpenChannel openChannel) => {
  // When the open channel is frozen.
};

ch.OnChannelUnfrozen(OpenChannel openChannel) => {
  // When the open channel is unfrozen.
};


SendBirdClient.AddChannelHandler(UNIQUE_HANDLER_ID, ch);

You should remove the channel handler where the activity is no longer valid.

SendBird.RemoveChannelHandler(UNIQUE_HANDLER_ID);

Connection Handler

You can register multiple connection handlers to detect connection status changes.

Typically you should register the connection handler in each activity.

SendBirdClient.ConnectionHandler ch = new SendBirdClient.ConnectionHandler ();

ch.OnReconnectFailed = () => {
    // Auto reconnecting failed. You should call `connect` to reconnect to SendBird.
};

ch.OnReconnectStarted = () => {
    // Network has been disconnected. Auto reconnecting starts.
};

ch.OnReconnectSucceeded = () => {
    // Auto reconnecting succeeded.
};

SendBirdClient.AddConnectionHandler(UNIQUE_HANDLER_ID, ch);

You should remove the connection handler where the activity is no longer valid.

SendBirdClient.RemoveConnectionHandler(UNIQUE_HANDLER_ID);

Push Notifications

You can setup Push Notifications so users can get messages when they are offline.

To make users offline, you must call SendBirdClient.Disconnect(). We recommend that set users offline by calling SendBirdClient.Disconnect() when your app goes background.

Push notification is only supported in group channels and not supported in open channels.

Android

Please visit our Android Push Notification page for more detail. Android Push Notification

iOS

Please visit our iOS Push Notification page for more detail. iOS Push Notification

Register and unregister push token in SendBird SDK

SendBirdClient.RegisterFCMPushTokenForCurrentUser(token, (SendBirdClient.PushTokenRegistrationStatus status, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }

    if (status == SendBirdClient.PushTokenRegistrationStatus.PENDING) {
        // Try registration after connection is established.
    }
});

You should call SendBirdClient.Connect to register the pending token

SendBirdClient.Connect(userId, (User user, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }

    if (SendBirdClient.GetPendingPushToken() == null) return;

    SendBirdClient.RegisterFCMPushTokenForCurrentUser(SendBirdClient.GetPendingPushToken(), (SendBirdClient.PushTokenRegistrationStatus status, SendBirdException e1) => {
        if (e1 != null) {
            // Error.
            return;
        }
    });
});

Then, SendBird messages start coming to offline users using push notifications and you should parse them and show them to users.

SendBird also sends an additional payload with "sendbird" key.

Android

message property is a simple string. e.g.) "Sender: Message".
payload property is a json string with full information of the request.

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    String message = remoteMessage.getData().get("message");
    JsonElement payload = new JsonParser().parse(remoteMessage.getData().get("sendbird"));
    sendNotification(message, payload);
}

private void sendNotification(String message, JsonElement payload) {  
  // Your own way to show notifications to users.
}

iOS

SendBird APNS Push notifications are sent with the following options.

  • alert : "{Sender Nickname}: {Text Message}"
  • sound : default
  • badge : total unread message count of each user
  • (You can disable "badge" count in SendBird Dashboard if you want)

You could parse the payload in "didReceiveRemoteNotification" and use it to handle user reactions.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler{

    NSString *alertMsg = [[userInfo objectForKey:@"aps"] objectForKey:@"alert"];
    NSDictionary *payload = [userInfo objectForKey:@"sendbird"];
      // Your custom way to parse data
    completionHandler(UIBackgroundFetchResultNewData);
}

Payload

Here is a format of each payload.

{
  "category": "messaging:offline_notification",
  "message": string,           // User input message
  "data": string,              // User custom data
  "mentioned": [string, ],     // Mentioned User IDs
  "unread_message_count": int, // Total unread message count of messaging channels
  "channel": {
    "channel_url": string,     // Group Channel URL
    "name": string,            // Group Channel name 
  },
  "channel_type": string,      // messaging, group_messaging, chat
  "sender": {
    "id": string,              // Sender's unique ID
    "name": string,            // Sender's nickname
  },
  "recipient": {
    "id": string,              // Recipient's unique ID
    "name": string,            // Recipient's nickname
  },
  files: []  // If a message is a file link, this array represents files
}

Notification Preference

If you have a setting for the push notification in your app, it can be turned on or off.

public void SetPushNotification(bool enable) {
    if (enable)
    {
        SendBirdClient.RegisterFCMPushTokenForCurrentUser(fcmRegToken, (SendBirdClient.PushTokenRegistrationStatus status, SendBirdException e) => {
            if (e != null) {
                // Error.
                return;
            }
        });
    }
    else 
    {
        // If you want to unregister the current device only, invoke this method.
        SendBirdClient.UnregisterFCMPushTokenForCurrentUser(fcmRegToken, (SendBirdException e) => {
            if (e != null) {
                // Error.
                return;
            }
        });

        // If you want to unregister the all devices of the user, invoke this method.
        SendBirdClient.UnregisterPushTokenAllForCurrentUser((SendBirdException e) => {
            if (e != null) {
                // Error.
                return;
            }
        });
    }
}

You can also set push notification on/off setting for a specific group channel.

// If you want to turn push notification for this channel on, set this true.
groupChannel.SetPushPreference(TRUE_OR_FALSE, (SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

If you want to snooze alarms (notifications) for some periods, SetDoNotDisturb is here for you.

// The current logged-in user doesn't receive push notifications during the specified time.
SendBirdClient.SetDoNotDisturb(TRUE_OR_FALSE, START_HOUR, START_MIN, END_HOUR, END_MIN, "America/Los_Angeles", (SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

Miscellaneous

Client SDK generated Error Codes

Errors on SendBird are defined as below.

Error Value Description
ERR_INVALID_INITIALIZATION 800100 Initialization failed
ERR_INVALID_PARAMETER 800110 Invalid parameters
ERR_NETWORK 800120 Routing error
ERR_NETWORK_ROUTING_ERROR 800121 Routing error
ERR_MALFORMED_DATA 800130 Malformed data
ERR_MALFORMED_ERROR_DATA 800140 Malformed error data
ERR_WRONG_CHANNEL_TYPE 800150 Wrong channel type
ERR_MARK_AS_READ_RATE_LIMIT_EXCEEDED 800160 Mark as read rate limit exceeded
ERR_QUERY_IN_PROGRESS 800170 Query is in progress
ERR_ACK_TIMEOUT 800180 Command ack timed out
ERR_LOGIN_TIMEOUT 800190 Login timed out
ERR_WEBSOCKET_CONNECTION_CLOSED 800200 Connection closed
ERR_WEBSOCKET_CONNECTION_FAILED 800210 Connection failed
ERR_REQUEST_FAILED 800220 Request failed

Server-generated Error Codes

These errors are not defined in the header file.

Code Description
400100 Parameter Error - String value is required
400101 Parameter Error - Number value is required
400102 Parameter Error - List value is required
400103 Parameter Error - Json value is required
400104 Parameter Error - Boolean value is required
400105 Parameter Error - Not all the required fields are arrived
400106 Parameter Error - Value must be a positive number
400107 Parameter Error - Value must be a negative number
400108 User doesn't have an access to channels or messages
400110 Parameter Error - Length of value is not valid
400111 Parameter Error - Unknown
400112 Parameter Error - Should provide two different values
400151 Parameter Error - Not allowed characters
400201 Object(Channel/User/Message) not found
400202 Unique constraint violation
400300 User Authentication Error - Deactivated user
400301 User Authentication Error - Deleted user or user not found
400302 User Authentication Error - Invalid access token
400303 User Authentication Error - Unexpected error
400304 User Authentication Error - Application not found
400305 User Authentication Error - User id is too long
400306 User Authentication Error - Plan quota exceeded
400307 User Authentication Error - Requests from authorized domain
400601 The push token registration failure
400602 The push token removal failure
400910 Requests are rate-limited
400920 Tried to access non-allowed features under your plan
500901 Unexpected errors
900010 Try to send messages without login
900020 Try to send messages to group channels not belong to the user
900021 Try to send messages after getting deactivated
900030 Try to send messages to the channels when the guest policy is read-only on dashboard
900041 The user is muted on this channel
900050 User cannot send messages to frozen channels
900060 Message is blocked by profanity filter
900070 Try to send messages to deleted channels
900080 You cannot send messages on 1-on-1 group channel when receiver is blocked
900081 You cannot send messages on 1-on-1 group channel when receiver is deactivated
900100 Try to enter the banned channel
900200 You are blocked because you sent too many messages in short period

Change Log

v3.0.5 (Jan, 20, 2017)

  • Speed up initial loading on some platforms.

v3.0.4 (Jan, 17, 2017)

  • Improved stability.
  • Fixed read receipt reset issue.

v3.0.3 (Dec 14, 2016)

  • Improved stability.

v3.0.2 (Dec 9, 2016)

  • Improved performance.
  • Improved stability.
  • Added user IDs filters and query type to GroupChannelListQuery.
  • Added channel custom type for OpenChannel and GroupChannel.
  • Fixed to call ChannelHandler.onChannelChanged when unread message count or last message has been updated.
  • Fixed to update last message of group channel when UserMessage or FileMessage is successfully sent.
  • Added custom type to messages.
  • Added group channel list search by member nicknames and user IDs.
  • Added creating and updating channel cover image with binary file.

v3.0.1 (Nov 21, 2016)

  • Faster connection time.
  • Improved stability.

v3.0.0 (Nov 4, 2016)

  • First release.