vdotok_connect 0.0.10 vdotok_connect: ^0.0.10 copied to clipboard
A new Flutter plugin.
vdotok_connect #
Getting Started #
IOS: #
Add the following entry to your Info.plist file, located in
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) Camera Usage!</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) Microphone Usage!</string>
Android: #
Ensure the following permission is present in your Android Manifest file
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Create Client Instance: #
First we need to create an instance of emitter client.
Emitter emitter = Emitter.instance;
Add listeners: #
Below described main helpful callbacks and listeners:
emitter.onConnect = (bool response)
{
// called when you are connected to emitter
};
emitter.onPresence = (String response)
{
// called when you get the presence of a User
};
emitter.onsubscribe = (Strin value)
{
// called when the User subscribes to a group
};
emitter.onMessage = (String mesg) async
{
// called whenever any pub/sub occurs
};
emitter.internetConnectivityCallBack = (String mesg)
{
// called whenever your device is connected to internet or disconnected from internet
};
Class used in ReadReceiptModel class to inform status of the message:
class ReceiptType {
static var sent = 1;
static var delivered = 2;
static var seen = 3;
}
Class to identify the type of file:
class MediaType {
static int image = 0;
static int audio = 1;
static int video = 2;
static int file = 3;
}
Class to identify the type of Message:
class MessageType {
static const String text = "text";
static const String media = "media";
static const String file = "file";
static const String thumbnail = "thumbnail";
static const String path = "path";
static const String typing = "typing";
static const String ftp = "ftp";
static const String acknowledge = "acknowledge";
static const String receipts = "receipts";
}
Packet for Publishing Messages
var sendMessage = {
"from": // your refId
"content": // text/file/image/video/,mp3
"id": // random Id,
"key": // group channel_key,
"subtype": // use this in case of media sharing file,image,video,audio i.e. MediaType.image
"fileExtension": // use this in case of media sharing i.e. .mp3, .doc, .mp4
"type": MessageType enum value mentioned above i.e. MessageType.text
"to": // channel_name
"isGroupMessage": false,
"date": // current date
"status": // ReceiptType enum value mentioned above i.e. ReceiptType.sent
"size": 0.0
};
SDK Methods: #
Use this method to connect socket.
emitter.connect(
String clientId, // in login/sign up response
bool reconnectivity, //true
String refId, // in login/sign up response
String authorizationToken, // in login/sign up response
String projectId,
String host, // in login/sign up response
String port // in login/sign up response
);
Subscription: #
Use this method to subscribe to a chat or group.
emitter.subscribe(String channelKey,String channelName);
SubscribePresence: #
Use this method to acknowledge the availability of the user.
emitter.subscribePresence(String channelKey, String channelName, bool changes, bool status)
Publish: #
Use this method to publish message of object type which can be of any type i-e text, audio, video, document, or image type.
emitter.publish(String channelKey, String channelName, Map<String, dynamic> sendMessage, int ttl);