开发者

Android and XMPP: Currently available solutions [closed]

开发者 https://www.devze.com 2023-02-05 23:10 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 3 years ago.

Improve this question

Which XMPP library would be the best choice nowadays for Android development?

  • I've been using the patched Smack library as is suggested in many other questions here in SO. However, that's a patched version of the Smack API from two years ago. And although it generally works well I'm exploring any other, more recent options.

  • I've been looking at the official Smack API and after a little research, it seems it might work just fine nowadays (although I have not tried it yet in a rea开发者_JAVA百科l application).

  • There's also another solution I came across, Beem's aSMACK library. Beem is a fairly new XMPP client for android and from what I understand they are using their own patched version of aSMACK.

  • Finally, there's aSMACK but that too hasn't been updated for quite some time (as the site suggests).

Do you have any other suggestions or can you explain why I should choose one of the above over the rest?


Smack

Smack is a open-source XMPP client library. Since version 4.1 it runs natively on Android. For more information have a look at the "Smack 4.3 Readme" and see the Smack project page at Ignite Realtime.


I recently stumbled across another open-source solution: jaxmpp2

jaxmpp2 also targets Android (and Java SE). I can't really say anything else about it, because I don't use jaxmpp2 in my Android/XMPP projects. But it looks like a valid alternative to aSmack.


Use qsmack for android

https://code.google.com/p/qsmack/downloads/list

Its the latest build for Android

I have worked on one to one chat, group chat, video transfer, audio transfer, last seen, change registration number... almost complete whats app. I have created lots of plugin on openfire


I would like to use libstrophe and jni. Goals to use this is cross platform, simple to use and performance. libstrophe is written in c so, it easy to write android makefile since the dependency is only openssl and expat lib. In my case, I'm using openssl and expat lib from libjingle which already port to android and ios. (Just need to port gyp file to android makefile or IOS project).

Below is my android makefile



    LOCAL_PATH:= $(call my-dir)/../../libstrophe-0.8.7

    SSL_PROJECT_PATH := openssl/libs/android

    include $(CLEAR_VARS)

    LOCAL_MODULE := openssl

    OPENSSL_LIB_NAME := lib$(LOCAL_MODULE).a

    LOCAL_CFLAGS := -DL_ENDIAN \
        -DOPENSSL_THREADS \
        -DPURIFY \
        -DTERMIO \
        -D_REENTRANT \
        -DOPENSSL_NO_HW \
        -DOPENSSL_NO_GOST \
        -DOPENSSL_NO_DTLS1 \
        -DOPENSSL_NO_RDRAND \
        -DOPENSSL_NO_RSAX \
        -Wall -pipe -fno-exceptions -fno-rtti -fstrict-aliasing -mfpu=neon -mfloat-abi=softfp


    OPENSSL_PATH := openssl/openssl
    OPENSSL_PATH_INC := $(LOCAL_PATH)/openssl/openssl

    LOCAL_C_INCLUDES := \
        $(OPENSSL_PATH_INC) \
        $(OPENSSL_PATH_INC)/include \
        $(OPENSSL_PATH_INC)/crypto \
        $(OPENSSL_PATH_INC)/crypto/asn1 \
        $(OPENSSL_PATH_INC)/crypto/evp \
        $(OPENSSL_PATH_INC)/crypto/modes \
        $(LOCAL_PATH)/openssl/config/android \
        $(LOCAL_PATH)/openssl

    LOCAL_ARM_MODE := arm
    LOCAL_CFLAGS += $(LOCAL_C_INCLUDES:%=-I%) -O3 -DANDROID_NDK


    LOCAL_SRC_FILES := \
        // here is openssl file which is defined in gyp

    LOCAL_SHORT_COMMANDS := true

    include $(BUILD_SHARED_LIBRARY)


    include $(CLEAR_VARS)

    STROPHE_PATH := $(LOCAL_PATH)
    EXPAT := expat-2.1.0
    OPENSSL_PATH := openssl/openssl
    OPENSSL_PATH_INC := $(LOCAL_PATH)/openssl/openssl


    EXPAT_SRC_FILES := \
        $(EXPAT)/lib/xmlparse.c \
        $(EXPAT)/lib/xmlrole.c \
        $(EXPAT)/lib/xmltok.c

    COMMON_CFLAGS := \
        -Wall \
        -Wmissing-prototypes -Wstrict-prototypes \
        -Wno-unused-parameter -Wno-missing-field-initializers \
        -fexceptions \
        -DHAVE_EXPAT_CONFIG_H \
        -DLOGGING -DANDROID \



    COMMON_C_INCLUDES += \
        $(LOCAL_PATH)/$(EXPAT)/lib \
        $(STROPHE_PATH) \
        $(STROPHE_PATH)/src \
        $(OPENSSL_PATH_INC) \
        $(OPENSSL_PATH_INC)/include \
        $(OPENSSL_PATH_INC)/crypto \
        $(OPENSSL_PATH_INC)/crypto/asn1 \
        $(OPENSSL_PATH_INC)/crypto/evp \
        $(OPENSSL_PATH_INC)/crypto/modes \
        $(LOCAL_PATH)/openssl/config/android \
        $(LOCAL_PATH)/openssl \
        ../android/jni


    STROPHE_SRC_FILES := src/auth.c \
        src/conn.c \
        src/ctx.c \
        src/event.c \
        src/handler.c \
        src/hash.c \
        src/jid.c \
        src/md5.c \
        src/sasl.c \
        src/scram.c \
        src/sha1.c \
        src/snprintf.c \
        src/sock.c \
        src/stanza.c \
        src/thread.c \
        src/tls_openssl.c \
        src/util.c \
        src/parser_expat.c \
        src/message.c \
        src/presence.c \
        src/roster.c


    JNI_SRC_FILES := ../android/jni/strophe-jni.c

    ifeq ($(TARGET_ARCH),arm)
        LOCAL_SDK_VERSION := 8
    else
        LOCAL_SDK_VERSION := 9
    endif

    LOCAL_ARM_MODE := arm
    LOCAL_SHORT_COMMANDS := true
    LOCAL_SYSTEM_SHARED_LIBRARIES := libc
    LOCAL_SHARED_LIBRARIES := openssl

    LOCAL_SRC_FILES := $(EXPAT_SRC_FILES)
    LOCAL_SRC_FILES += $(STROPHE_SRC_FILES)
    LOCAL_SRC_FILES += $(JNI_SRC_FILES)

    LOCAL_CFLAGS += $(COMMON_CFLAGS)
    LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
    LOCAL_CFLAGS += $(LOCAL_C_INCLUDES:%=-I%) -O3 -DANDROID_NDK
    LOCAL_C_INCLUDES += $(COMMON_C_INCLUDES)


    LOCAL_MODULE:= libnativeclient
    LOCAL_MODULE_TAGS := optional

    include $(BUILD_SHARED_LIBRARY)



You can use Tigase JaXMPP Client Library - it's very versatile and you can use it for both JavaSE applications and for Android development. It's actively developed and Tigase Messenger for Android (Play Store) is based on it.

There is a Basic library documentation wiki page with a couple of examples and for details you should refere to javadocs


Using Smack 4.1 Readme and Upgrade Guide

Using Android studio 2.3, Recently I have implemented a demo in a very simple way.

-> Just Add gradle dependency in app level gradle as below

compile "org.igniterealtime.smack:smack-tcp:4.1.0"

// Optional for XMPPTCPConnection

compile "org.igniterealtime.smack:smack-android-extensions:4.1.0"

-> Configure Connection Configuration
NOTE : Call this in AsyncTask or in other background thread

 XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
                    .setUsernameAndPassword("Your Username here", "Your Password here")
                    .setHost("Host name here")
                    .setServiceName("Your service name here")
                    .setPort(Your port number here)
                    .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled) //Disable or enable as per development mode
                    .setDebuggerEnabled(true) // to view what's happening in detail
                    .build();

-> Use isConnected() and isAuthenticated()

-> Use ChatManager for add chatListener.


You can use QuickBlox1 for free.

It provides XMPP server out of the box with lots of features, you can read about features there http://quickblox.com/developers/Chat

Here is an example how to start using QuickBlox with aSmack library http://quickblox.com/developers/Android_XMPP_Chat_Sample

0

精彩评论

暂无评论...
验证码 换一张
取 消