Build messenger with chat and video calling using QuickBlox API and SDK

dependencies: quickblox_sdk: ^0.6.7-betaimport 'package:quickblox_sdk/quickblox_sdk.dart';
const String APP_ID = "XXXXX"; 
const String AUTH_KEY = "XXXXXXXXXXXX";
const String AUTH_SECRET = "XXXXXXXXXXXX";
const String ACCOUNT_KEY = "XXXXXXXXXXXX";
const String API_ENDPOINT = ""; //optional
const String CHAT_ENDPOINT = ""; //optional
try {
await QB.settings.init(APP_ID, AUTH_KEY, AUTH_SECRET, ACCOUNT_KEY, apiEndpoint: API_ENDPOINT, chatEndpoint: CHAT_ENDPOINT);
} on PlatformException catch (e) {
// Some error occured, look at the exception message for more details
}
try { 
QBLoginResult result = await QB.auth.login(login, password);
QBUser qbUser = result.qbUser;
QBSession qbSession = result.qbSession;
} on PlatformException catch (e) {
// Some error occured, look at the exception message for more details
}
try {
QBDialog createdDialog = await QB.chat.createDialog(occupantsIds, dialogName, dialogType: dialogType);
} on PlatformException catch (e) {
// Some error occured, look at the exception message for more details
}
await QB.chat.subscribeMessageEvents(dialogId, eventName, (data) {
//receive a new message
Map<String, Object> map = new Map<String, dynamic>.from(data);
String messageType = map["type"];
if (messageType == QBChatEvents.RECEIVED_NEW_MESSAGE) { Map<String, Object> payload = new Map<String, dynamic>.from(map["payload"]); String messageBody = payload["body"];
String messageId = payload["id"];
}
} on PlatformException catch (e) {
// Some error occured, look at the exception message for more details
}
// eventName - QBChatEvents.RECEIVED_NEW_MESSAGE try { 
await QB.chat.unsubscribeMessageEvents(dialogId, eventName);
} on PlatformException catch (e) {
// Some error occured, look at the exception message for more details
}
try { await QB.chat.sendMessage(dialogId, body: messageBody, saveToHistory: true); } on PlatformException catch (e) { 
// Some error occured, look at the exception message for more details
}

--

--

intforce software is software service company and providing complete IT solution with fresh perspective. https://intforcesoftware.com/

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store