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 Answers
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

- 18,156
- 10
- 49
- 70
-
Well, Nativescript uses a Javascript Virtual machine so I'm confused how the browser point you mention is a problem, in their page you can read "Generally speaking, NativeScript tries to use the latest stable releases of both V8 and JavaScriptCore; therefore the ECMAScript language support in NativeScript for iOS is nearly identical to the support in desktop Safari, and the support in NativeScript for Android is nearly identical to the support in desktop Chrome.", but I'll definitely check out xmpp.js as for ConnectyCube, it's out of my reach financially speaking. – Daniel Arechiga Jan 23 '19 at 19:25
-
Ok I just posted here what's in their title, so not sure about stanza.io. But I can say for sure xmpp.js works for NativeScript well – Rubycon Jan 23 '19 at 19:50
-
So I went through the painof trying to get stanza to work with nativescript and had no luck, I also checked that tutorial over there and it didn't help much either, has anyone found a reliable solution? – Daniel Arechiga Aug 07 '19 at 18:09
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.

- 21,753
- 3
- 20
- 41
-
'nativescript-xmpp-client' is a potential way, but the latest commit was about 2.5 years ago, so I'm not sure whether it still works – Rubycon Jan 23 '19 at 13:18
-
@Rubycon it's not an optimal alternative as it doesn't support wss. See https://github.com/samuelagm/nativescript-xmpp-client/issues/3 – Daniel Arechiga Jan 23 '19 at 19:14
-
@DanielArechiga I think you do not need WSS on mobile since a TCP socket connection is used there which is a quite standard – Rubycon Jan 23 '19 at 19:20
-
@Rubycon it's not about need, I'm concerned about latency, bandwidth use and overhead. – Daniel Arechiga Jan 23 '19 at 19:52
-
I can say you for sure a plain TCP/TLS connection works faster than WSS since WSS is a more higher abstraction level and based itself on top of TCP – Rubycon Jan 23 '19 at 19:54
-
1Apologies, I thought we were comparing BOSH vs websocket, of course, plain TCP is always faster, thanks for your answers – Daniel Arechiga Jan 28 '19 at 23:55