[英]QuickBlox : Notify web client (JavaScript SDK) when new Private chat is created from Android client
Not able to notify the web-client when a new Private chat is created from Android client using QuickBlox SDK. 使用QuickBlox SDK从Android客户端创建新的私人聊天时无法通知Web客户端。 Went through the documentation but couldn't find the solution. 通过文档但无法找到解决方案。
Here is my code for creating a Private chat. 这是我创建私人聊天的代码。
QBPrivateChatManager qbPrivateChatManager = QBChatService.getInstance().getPrivateChatManager();
final String finalAgent = agent;
qbPrivateChatManager.createDialog(Integer.parseInt(agent), new QBEntityCallback<QBDialog>() {
@Override
public void onSuccess(QBDialog qbDialog, Bundle bundle) {
Log.e(TAG, "success ");
}
@Override
public void onError(QBResponseException e) {
Log.e(TAG, "Failed");
}
});
I am able to create the Private chat but the recipient wont know about it until he/she refreshes the window. 我可以创建私人聊天,但收件人不会知道它,直到他/她刷新窗口。
To notify all occupants that you created a group chat we use chat notifications - it's simple chat message with extra parameters inside. 要通知所有占用者您创建了群组聊天,我们会使用聊天通知 - 这是一个简单的聊天消息,里面有额外的参数。 These parameters used to separate chat notifications from regular text chat messages: 这些参数用于将聊天通知与常规文本聊天消息分开:
notifyOccupants(createdDialog.occupants_ids, createdDialog._id);
function notifyOccupants(dialogOccupants, newDialogId) {
dialogOccupants.forEach(function(itemOccupanId, i, arr) {
if (itemOccupanId != currentUser.id) {
var msg = {
type: 'chat',
extension: {
notification_type: 1,
_id: newDialogId,
},
};
QB.chat.send(itemOccupanId, msg);
}
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.