1

Not able to notify the web-client when a new Private chat is created from Android client using QuickBlox SDK. 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.

ASP
  • 3,645
  • 1
  • 31
  • 45

1 Answers1

0

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);
    }
  });
}
Mayur Shah
  • 3,344
  • 1
  • 22
  • 41