connectycube_sdk 3.0.3 copy "connectycube_sdk: ^3.0.3" to clipboard
connectycube_sdk: ^3.0.3 copied to clipboard

Flutter SDK for messaging, video calling and push notifications. WebRTC and XMPP based.

example/example.md

Init ConnectyCube SDK #

String appId = "";
String authKey = "";

init(appId, authKey);
copied to clipboard

Create session #

CubeUser user = CubeUser(login: "user_login", password: "super_sequre_password");

createSession(user).then((cubeSession){
  print("Session was created");
}).catchError((error){
  print("Error was occured during create sessin");
});
copied to clipboard

Login to the chat #

CubeUser user = CubeUser(id: 123456, login: "user_login", password: "super_sequre_password");
    
CubeChatConnection.instance.login(user).then((user){
  print("Success login to the chat");
}).catchError((error){
  print("Error was occured during login to the chat");
});
copied to clipboard

Dialogs #

All chats between users are organized in dialogs. The are 3 types of dialogs:

  • 1-1 chat - a dialog between 2 users.
  • group chat - a dialog between specified list of users.
  • public group chat - an open dialog. Any user from your app can chat there.
  • broadcast - chat where a message is sent to all users within application at once. All the users from the application are able to join this group. Broadcast dialogs can be created only via Admin panel.

You need to create a new dialog and then use it to chat with other users. You also can obtain a list of your existing dialogs.

Create new dialog #

Create 1-1 chat #

You need to pass type = CubeDialogType.PRIVATE and an id of an opponent you want to create a chat with:

CubeDialog newDialog = CubeDialog(
    CubeDialogType.PRIVATE,
    occupantsIds: [56]);

createDialog(newDialog)
    .then((createdDialog) {})
    .catchError((error) {});
copied to clipboard

Create group chat #

You need to pass type = CubeDialogType.GROUP and ids of opponents you want to create a chat with:

CubeDialog newDialog = CubeDialog(
    CubeDialogType.GROUP,
    name: "Hawaii relax team",
    description: "Some description",
    occupantsIds: [56, 98, 34],
    photo: "https://some.url/to/avatar.jpeg");

  createDialog(newDialog)
      .then((createdDialog) {})
      .catchError((error) {});
copied to clipboard

Create public group chat #

It's possible to create a public group chat, so any user from you application can join it. There is no a list with occupants,
this chat is just open for everybody.

You need to pass type = CubeDialogType.PUBLIC and ids of opponents you want to create a chat with:

CubeDialog newDialog = CubeDialog(
    CubeDialogType.PUBLIC,
    name: "Blockchain trends",
    description: "Public dialog Description",
    photo: "https://some.url/to/avatar.jpeg");

createDialog(newDialog)
    .then((createdDialog) {})
    .catchError((error) {});
copied to clipboard

Send/Receive chat messages #

CubeDialog cubeDialog;  // some dialog, which must contains opponent's id in 'occupantsIds' for CubeDialogType.PRIVATE and
                        // 'dialogId' for other types of dialogs
CubeMessage message = CubeMessage();
message.body = "How are you today?";
message.dateSent = DateTime.now().millisecondsSinceEpoch;
message.markable = true;
message.saveToHistory = true;
      
cubeDialog.sendMessage(message)
    .then((cubeMessage) {})
    .catchError((error) {});

// to listen messages
ChatMessagesManager chatMessagesManager = CubeChatConnection.instance.chatMessagesManager;
chatMessagesManager.chatMessagesStream.listen((newMessage) {
    // new message received
}).onError((error) {
    // error received
});
copied to clipboard

Calls #

Setup P2PClient #

P2PClient callClient = P2PClient.instance; // returns instance of P2PClient
copied to clipboard

Create call session #

Set<int> opponentsIds = {};
int callType = CallType.VIDEO_CALL; // or CallType.AUDIO_CALL

P2PSession callSession = callClient.createCallSession(callType, opponentsIds);
copied to clipboard

Start call #

Map<String, String> additionalInfo = {};
callSession.startCall(additionalInfo);
copied to clipboard

Accept call #

Map<String, String> additionalInfo = {}; // additional info for other call members
callSession.acceptCall(additionalInfo);
copied to clipboard

End a call #

Map<String, String> additionalInfo = {}; // additional info for other call members
callSession.hungUp(additionalInfo);
copied to clipboard

Conference Calls #

Setup ConferenceClient #

ConferenceClient callClient = ConferenceClient.instance; // returns instance of ConferenceClient
copied to clipboard

Create call session #

ConferenceClient callClient = ConferenceClient.instance;
int callType = CallType.VIDEO_CALL; // or CallType.AUDIO_CALL

ConferenceSession callSession = callClient.createCallSession(currentUserId, callType: callType);
copied to clipboard

Join video room #

callSession.joinDialog(roomId, ((publishers) {
    startCall(roomId, opponents, callSession.currentUserId);// event by system message e.g.
  }
}));
copied to clipboard

Subscribe/unsubscribe #

callSession.subscribeToPublisher(publisher)
copied to clipboard
callSession.unsubscribeFromPublisher(publisher);
copied to clipboard

Leave #

callSession.leave();
copied to clipboard

Custom objects #

Create Custom object #

CubeCustomObject cubeCustomObject = CubeCustomObject('TestClassName');
cubeCustomObject.fields = {
    integerField: 987,
    doubleField: 6.54,
    booleanField: true,
    stringField: 'Some string',
};

createCustomObject(cubeCustomObject)
    .then((createdObject) {})
    .catchError((error) {});
copied to clipboard

Get Custom object #

String id = '5f985984ca8bf43530e81233';
getCustomObjectById('TestClassName', id)
    .then((object) {})
    .catchError((error) {});
copied to clipboard

Update Custom object #

Map<String, dynamic> params = {
    'stringField': 'Updated string'
};

String id = '5f985984ca8bf43530e81233';
updateCustomObject('TestClassName', id, params)
    .then((updatedObject) {})
    .catchError((error) {});
copied to clipboard

Delete Custom object #

String id = '5f985984ca8bf43530e81233';
deleteCustomObjectById('TestClassName', id)
    .then((voidResult) {})
    .catchError((error) {});
copied to clipboard
78
likes
120
points
927
downloads

Publisher

verified publisherconnectycube.com

Weekly Downloads

2024.09.13 - 2025.03.28

Flutter SDK for messaging, video calling and push notifications. WebRTC and XMPP based.

Homepage
View/report issues

Documentation

Documentation
API reference

License

LGPL-3.0 (license)

Dependencies

collection, crypto, dart_webrtc, device_info_plus, flutter, flutter_webrtc, http, http_parser, intl, mime, objectid, path, universal_io, uuid, web, web_socket_channel, webrtc_interface, xmpp_stone

More

Packages that depend on connectycube_sdk