XMPP strophe file transfer

Hi,
I am developing an ionic-cordova application with chat by Openfire.
I can’t get the strophe.si-filetransfer.js plugin to work
This the declaration in index, html:

  <script src="/assets/xmpp/strophe.si-filetransfer.js"></script>
  <script src="/assets/xmpp/strophe.ibb.js"></script>

and this in file .ts:

 import { Strophe } from 'strophe.js';
.......
.......

  this.connection.si_filetransfer.addFileHandler(self.fileHandler);
  this.connection.ibb.addIBBHandler(self.ibbHandler);

but connection.si_filetransfer’ and ‘connection.ibb’ are always ‘undefined’

i tried installing ‘npm strophejs-plugins’ but it doesn’t help

Can anyone help me?

Hi, first of all beware importing js files like this , even if your are loading this js file in async mode you should really think about it since it will impact your app booting time.

You should install that strophe.js through npm if you want to import that package, otherwise you could try replacing your import { Strophe } from ‘strophe.js’ and do something like:

(supposing Strophe.js is exporting the object strophe, I’m pretty sure it’s case sensitive)

declare var strophe;

and then you use your object’s methods, for example:

strophe.si-filetransfer.addHandler(params);

Thanks for your help,
if I understand correctly you advise me to use the npm packages.

Do you know if SI File Transfer in https://www.npmjs.com/package/strophejs-plugins
should works?

because using npm packages connection.si_filetransfer is still undefined
how can I import it?

hi,
I’n sorry to be late
it was a problem of include plugin from node module, this code works:

import { Strophe } from 'strophe.js';
require('strophejs-plugin-http-file-upload');
require('strophejs-plugins/si-filetransfer/strophe.si-filetransfer.js');
require('strophejs-plugins/ibb/strophe.ibb.js');

thank for all help