Skip to content

Getting error in sending system notification #425

Open
@sanidhya1712

Description

@sanidhya1712

I am using quickblox system notification in my platform for sending live notifications in NodeJs.

First time I try to send live notification, It works perfectly fine but when I try to send notification afterwards, I am getting the following error, even though it send the notification.

TypeError: Cannot read property 'querySelector' of null
at Object.getElementText (/abc/dropN/did/node_modules/quickblox/src/modules/chat/qbChatHelpers.js:123:26)
at ChatProxy._onSystemMessageListener (/abc/dropN/did/node_modules/quickblox/src/modules/chat/qbChat.js:641:42)
at Client. (/abc/dropN/did/node_modules/quickblox/src/modules/chat/qbChat.js:862:30)
at Client.emit (events.js:315:20)
at Client.EventEmitter.emit (domain.js:482:12)
at Client._handleStanza (/abc/dropN/did/node_modules/node-xmpp-client/lib/Client.js:227:12)
at Client.onStanza (/abc/dropN/did/node_modules/node-xmpp-client/lib/Client.js:221:8)
at Connection.emit (events.js:315:20)
at Connection.EventEmitter.emit (domain.js:482:12)
at Connection.onStanza (/abc/dropN/did/node_modules/node-xmpp-core/lib/Connection.js:377:10)
at StreamParser. (/abc/dropN/did/node_modules/node-xmpp-core/lib/Connection.js:231:10)
at StreamParser.emit (events.js:315:20)
at StreamParser.EventEmitter.emit (domain.js:482:12)
at SaxLtx. (/abc/dropN/did/node_modules/@xmpp/streamparser/index.js:69:14)
at SaxLtx.emit (events.js:315:20)

Due to this, my code keeps crashing. Is there any way through which I can prevent this error and send the system notifications seamlessly.

Here is my code through which I am sending these notification.

QB.init(APPLICATION_ID, AUTH_KEY, AUTH_SECRET, ACCOUNT_KEY);
var params = {
userId: 121312,
password: XXXXXYYYYYYY,
};
console.log(params);
QB.createSession({
userId: 121312,
password: XXXXXYYYYYYY,
}, function (err, result1) {
if (err) {
console.log('Something went wrong: ' + JSON.stringify(err));
reject(err)
} else {
console.log("new session created---", JSON.stringify(result1));
QB.chat.connect({
userId: 121312,
password: XXXXXYYYYYYY,
}, async function (error, contactList) {
if (error) {
console.log('not connected to chat', error);
reject(error)
} else {
console.log(error, 'connected to chat', contactList);
var message = {
body: "System_notification",
extension: {
param1: "value1",
param2: "value2",
},
};
var opponentId = 12321321;
try {
message.id = QB.chat.sendSystemMessage(opponentId, message);
console.log("Notification sent", message.id)
resolve("notification sent")
// or message.id = QB.chat.sendSystemMessage(opponentId, message) if message ID is needed
} catch (e) {
if (e.name === "ChatNotConnectedError") {
console.log("not connected")
reject(e)
}
}
}
});
}
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions