Skip to content

This is a xep0357 App server. You can host it on your machine/server without exposing things to third party app server.

License

Notifications You must be signed in to change notification settings

hosannahighertech/xmpp-app-server

 
 

Repository files navigation

Buy Me A Coffee

simple xmpp push appserver

Simple XEP-0357 xmpp push app server . External component for ejabberd server (XEP-0357). You can try with other xmpp servers.

Liked my work ? support me If you want to have a quick conversation, you can connect via linkedin. linkedin

myxmpp.sql file contains the basic sql commands to set things in mysql. Just import it to your mysql/maridb server.

Client (App user) send following iq stanza to register his/her token.

Device type can be integer representing android or ios. You can remove it if it serves no purpose to you. node value can be any value decided by you to recognise that user wants to register iq id can be any string that recognises this stanza. You can use token value to put into DB. Like I did in this project.

<iq from="user1ofapp@192.168.1.20" id="cXo5bNCF6wgD" to="localhost" type="set">
  <command xmlns="http://jabber.org/protocol/commands" action="execute" node="register-push">
  <x xmlns="jabber:x:data" type="submit">
      <field var="token">
        <value>yourFCMToken-generatedbyuserdevice</value>
      </field>
      <field var="device_type">
        <value>1</value>
      </field>
    </x>
  </command>
</iq>

Client (App user) send following iq stanza to his xmpp server(ejabberd).

Here NODE value can be anything that can help distinguish user . You can use local part of user's JID ex: for user1ofapp@192.168.1.20 use 'user1ofapp' This node value will be used to identify the record in mysql server.

Here JID value should be the external component if ie: XMPP_EXTERNAL_COMPONENT_DOMAIN from env file.

<iq type='set' id='x42rtytr'>
  <enable xmlns='urn:xmpp:push:0' jid='localhost' node='user1ofapp'>
  </enable>
</iq>

Edit your ejabberd config file as follows

listen:
    port: 5347 # XMPP_EXTERNAL_COMPONENT_PORT
    module: ejabberd_service
    access: all
    shaper_rule: fast
    ip: "::"
    hosts:
      "localhost": # XMPP_EXTERNAL_COMPONENT_DOMAIN
        password: "password" # XMPP_EXTERNAL_COMPONENT_PASSWORD

##### Add include sender and body in mod push module of your ejabberd server according to your needs.
mod_push: 
    include_sender: true
    include_body: true

Env file which contains the necessary values

GOOGLE_APPLICATION_CREDENTIALS="fcm/fcm-service-account-file.json"

DB_HOST=localhost
DB_NAME=myxmpp
DB_USERNAME=admin
DB_PASSWORD=password
DB_TIMEZONE=Z

XMPP_ADDRESS=192.168.1.10
XMPP_EXTERNAL_COMPONENT_PORT=5347
XMPP_EXTERNAL_COMPONENT_DOMAIN=localhost
XMPP_EXTERNAL_COMPONENT_PASSWORD=password

Meaning of some commonly used variables/files used in this project

device_type field contains values which identifies device type ie: for 1 I am assuming: 1 = Android (so will trigger FCM notification) fcm folder should contain fcm service account file will same name or change name in .env file

About

This is a xep0357 App server. You can host it on your machine/server without exposing things to third party app server.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%