cpass_flutter_sdk 1.0.2 copy "cpass_flutter_sdk: ^1.0.2" to clipboard
cpass_flutter_sdk: ^1.0.2 copied to clipboard

Dart and flutter package to use Comunia SDK. This version includes the APIs related to CHAT functionality only.

A library for Dart developers to connect their flutter app to Comunia.io Platform.

Usage #

Installing the package #

Run

pub get cpass_flutter_sdk

Connecting to Comunia platform #

You need to obtain a API key from comunia platform to start using this package. So first go to Comunia Website and register for account and create a new App where you can find your API Key.

To initialize the ComuniaClient you need below paramters.

And finally,

import  'package:cpass_flutter_sdk/cpass_flutter_sdk.dart';

ComuniaClient client =  ComuniaClient(URL, API_KEY,  USER_ID);

Sending a message to another user. #

To send a message simple call sendNewMessage method like below.

var receiver = 'recever-user-id';
var message = 'hello world';

client.sendNewMessage(receiver, message);

Receiving a message from another user. #

To receive a message from another user, you have to listen for a StreamSubscription as below.

client.onNewMessage.listen((message) {
	print(message);
});

Here the message object has below attributes.

  • messageId: Unique id for the message
  • text: Content of the message
  • from: User Id of the sender
  • receivedTime: Unix timestamp to indicate when that message received to the server

Further comunia sdk can use to receive and send events when a user start to typing, stopped typing and seen a received message.

Send and receive when a user START typing a new message. #

To notify the other party a user is typing a new message send below event.

client.sendOnStartTyping("other_user_id")

To receive this event you should subscribe for a StreamSubscription as below.

client.onOtherStartTyping.listen((userId) {

})

Send and receive when a user STOP typing a new message. #

To notify the other party a user stopped typing a message send below event.

client.sendOnStopTyping("other_user_id")

To receive this event you should subscribe for a StreamSubscription as below.

client.onOtherStopTyping.listen((userId) {

})

Send and receive when a user SEEN a message already sent. #

To notify the sender party that receiver has seen a message that was received via listning to onNewMessage.

client.sendMessageViewed("sender_user_id", "message_id_of_received_message")

To receive this event you should subscribe for a StreamSubscription as below.

client.onOtherSeenMessage.listen((data) {

})

Here the data object has below attributes.

  • from: User Id of the sender
  • messageId: Message id that was seen by the sender
2
likes
40
points
17
downloads

Publisher

unverified uploader

Weekly Downloads

Dart and flutter package to use Comunia SDK. This version includes the APIs related to CHAT functionality only.

Homepage

License

BSD-3-Clause (license)

Dependencies

socket_io_client, uuid

More

Packages that depend on cpass_flutter_sdk