如何在android中连接ejabberd和FCM

时间:2017-01-17 12:32:51

标签: android firebase xmpp firebase-cloud-messaging ejabberd

有任何方法可以连接FCM和ejabbered

    mConnection.addAsyncStanzaListener(stanzaListener, serverFilter);
    try {

        final String refreshedToken = FirebaseInstanceId.getInstance().getToken();

        String childElementNameTicket = "push";
        String childElementNamespaceTicket = "p1:push";

        IQ iq = new IQ(childElementNameTicket, childElementNamespaceTicket) {
            @Override
            protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
                xml.append("<iq type='set' id=" + "'" + refreshedToken + "'" + ">");
                xml.append("<push xmlns='p1:push'><keepalive max=\"30\"/>");
                xml.append("<keepalive max=\"30\"/>");
                xml.append("<session duration=\"60\"/>");
                xml.append("<body send=\"all\" groupchat=\"true\" from=" + "\"" + mUsername + "\"/>");
                xml.append("<status type=\"xa\">Text Message when in push mode</status>");
                xml.append("<offline>true</offline>");
                xml.append("<notification><type>fcm</type><id>"+ refreshedToken + "</id></notification>");
                xml.append("<appid>com.azova</appid>");
                xml.append("</push>");
                xml.append("</iq>");
                return xml;
            }
        };

        iq.setType(IQ.Type.set);
        iq.setStanzaId(refreshedToken);

        mConnection.sendPacket(iq);

    } catch (Exception e) {
        e.printStackTrace();
    }

}

}

的logcat ::

01-17 17:55:55.492 21135-24998/W/AbstractXMPPConnection: Connection closed with error
                                                                   java.lang.IllegalStateException: Could not transform string 'xml_not_well_formed' to XMPPErrorCondition
                                                                       at org.jivesoftware.smack.packet.StreamError$Condition.fromString(StreamError.java:193)
                                                                       at org.jivesoftware.smack.util.PacketParserUtils.parseStreamError(PacketParserUtils.java:828)
                                                                       at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1015)
                                                                       at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:956)
                                                                       at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:971)
                                                                       at java.lang.Thread.run(Thread.java:818)
                                                                    Caused by: java.lang.IllegalArgumentException: xml_not_well_formed is not a constant in org.jivesoftware.smack.packet.StreamError$Condition
                                                                       at java.lang.Enum.valueOf(Enum.java:200)
                                                                       at org.jivesoftware.smack.packet.StreamError$Condition.valueOf(StreamError.java:155)
                                                                       at org.jivesoftware.smack.packet.StreamError$Condition.fromString(StreamError.java:191)
                                                                       at org.jivesoftware.smack.util.PacketParserUtils.parseStreamError(PacketParserUtils.java:828) 
                                                                       at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1015) 
                                                                       at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:956) 
                                                                       at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:971) 
                                                                       at java.lang.Thread.run(Thread.java:818) 
01-17 17:55:55.492 21135-24998/I/ABCD SMACK_connectionClosedOnError:: Could not transform string 'xml_not_well_formed' to XMPPErrorCondition

0 个答案:

没有答案