Running following code with ejabberd server at back and it performs its tasks. However, this doesn’t show up in ejabberd log/debug file and/or IQ response isn’t getting back to client device (smack 4.4.2). How can I get the IQ response back, do we need to add code in this code for returning the IQ result/response? or I am missing something?
DataForm.Builder xep0004 = DataForm.builder(DataForm.Type.submit); //new DataForm(DataForm.Type.submit);
TextSingleFormField.Builder token = FormField.builder("token");
token.setValue(App.user_settings.getFirebaseToken(App.mContext));
TextSingleFormField.Builder device_id = FormField.builder("android-id"); //new FormField("device-id");
device_id.setValue(App.user_settings.getECCID(App.mContext));
xep0004.addField(token.build());
xep0004.addField(device_id.build());
IQ pushStanza = new IQ("command", "http://jabber.org/protocol/commands") {
@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
xml.attribute("action", "execute");
xml.attribute("node", "register-push-fcm");
xml.setEmptyElement();
return xml;
}
};
pushStanza.setType(IQ.Type.set);
pushStanza.setTo(JidCreate.from("p2.pgpnet.fi"));
pushStanza.setFrom(connection.getUser());
pushStanza.addExtension(xep0004.build());
if (connection.isSmEnabled()) {
try {
connection.addStanzaIdAcknowledgedListener(pushStanza.getStanzaId(), new StanzaListener() {
@Override
public void processStanza(Stanza stanza) throws NotConnectedException, InterruptedException, SmackException.NotLoggedInException {
Log.e("stanza result", stanza.toXML().toString());
// registerTokenToXmpp1();
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
connection.sendStanza(pushStanza);