简体   繁体   中英

How to Receive messages from quickblox_id not registered with createChat in Android?

How to Receive messages from quickblox_id not registered with createChat in Android? as titled.

editted:

public static void register_general_chat(final QBMessageListener<QBChat> callback) {
    privateChatManagerListener = new QBPrivateChatManagerListener() {
        @Override
        public void chatCreated(final QBPrivateChat privateChat, final boolean createdLocally) {
            NSLog("chatCreated.createdLocally=" + createdLocally);
            if (!createdLocally) {
                privateChat.addMessageListener(callback);
            }
        }
    };
    NSLog("chat_manager added");
    privateChatManager.addPrivateChatManagerListener(privateChatManagerListener);
}

When you first time receive a message in some chat - next callback will be fired:

QBPrivateChatManagerListener privateChatManagerListener = new QBPrivateChatManagerListener() {
    @Override
    public void chatCreated(final QBPrivateChat privateChat, final boolean createdLocally) {
        if(!createdLocally){
            privateChat.addMessageListener(privateChatMessageListener);
        }
    }
};
QBChatService.getInstance().getPrivateChatManager().addPrivateChatManagerListener(privateChatManagerListener);

And then messages will come to QBMessageListener

More info here http://quickblox.com/developers/Android_XMPP_Chat_Sample#Chat_in_1-1_private_dialog

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM