How to implement XMPP communication in Nativescript?

410 Views Asked by At

Is there any limitation in using a library like stanza.io for communication with an XMPP server like MongooseIM in Nativescript? What other alternatives are there?

2

There are 2 best solutions below

6
On

You will have to find a third party server or host your own one that implements XMPP protocols and connect to same using Websockets or XMPP plugin from your {N} application.

FYI, This XMPP plugin implements the same pod library explained in the MongooseIM docs, but the JavaScript apis are not fully implemented so you might have to access the native apis directly as needed.

You may also refer nativescript-xmpp-client, another exampel for XMPP implementation.

3
On

If stanza.io supports NativeScript then there should not be any limitations.

On their GitHub main pager they say it's a Modern XMPP in the browser, with a JSON API. So it's mainly for browser env and I'm not sure about NativeScript.

As an alternative way - there is a xmpp.js lib which supports NativeScript. Their doc is a little bit shitty, but using src code there is a way to integrate successfully it.

There is a guide on how to use it for ReactNative, but you can some part from it for NativeScript, especially these part that are connected to the lib itself. https://medium.com/@connectycube/xmpp-real-time-chat-in-react-native-8d6d5d23dd47

Also you can use some ready XMPP high level platforms for Chat, e.g. https://connectycube.com/2018/12/11/connectycube-textchat-code-sample-for-nativescript/ In this case you do not need to carte about XMPP server installation and monitoring