Git Product home page Git Product logo

openfire-pushserver-plugin's Introduction

Build Status

Openfire Push Server Plugin

An XEP-0357: Push Notifications app server that relays push messages between the user’s server and FCM (Firebase Cloud Messaging) or APNS (Apple Push Notification Service).

Building

This project is using the Maven-based Openfire build process, as introduced in Openfire 4.2.0. To build this plugin locally, ensure that the following are available on your local host:

  • A Java Development Kit, version 7 or (preferably) 8
  • Apache Maven 3

To build this project, invoke on a command shell:

$ mvn clean package

Upon completion, the openfire plugin will be available in target/pushserver-openfire-plugin-assembly.jar. This file should be renamed to pushserver.jar

Installation

Copy pushserver.jar into the plugins directory of your Openfire server, or use the Openfire Admin Console to upload the plugin. The plugin will then be automatically deployed.

To upgrade to a new version, copy the new pushserver.jar file over the existing file.

Configuration

After installing plugin, you should fill the fields under the page `Server -> Server Settings -> Push Server Properties.

Note: After filling and saving values, you should restart the plugin.

iOS

Android

  • FCM Project Id
  • FCM Credential File Content (Service Account Json File Content)

Both of these can be found in your Firebase console, under Project Settings:

  • The ID is found in the "General" tab
  • The Service Account JSON file can be downloaded from the "Service Account" tab.

Client Configuration

Registering Devices

  • Clients need to register with push server and get node and secret information

iOS

<iq from="[email protected]/mobile" id="x20" to="push.example.com" type="set">
    <command xmlns="http://jabber.org/protocol/commands" action="execute" node="register-push-apns">
        <x xmlns="jabber:x:data" type="submit">
            <field var="token">
                <value>243CA5F2A4EE00B66E3208CD05C962A30EFA80B2D9F8DD508CE8182E04EAB695</value>
            </field>
            <field var="device-id">
                <value>0523AD60-ADD0-45A4-8D05-DC1AC59BB1CA</value>
            </field>
        </x>
    </command>
</iq>
<iq from="push.example.com" id="x20" to="[email protected]/mobile" type="result">
    <command xmlns="http://jabber.org/protocol/commands" action="complete" node="register-push-apns">
        <x xmlns="jabber:x:data" type="form">
            <field type="text-single" var="node">
                <value>37Ni514izxHG</value>
            </field>
            <field type="text-single" var="secret">
                <value>Zt9z9wOtAUOSYCtYC7a5OORa</value>
            </field>
        </x>
    </command>
</iq>

Android

<iq from="[email protected]/mobile" id="x20" to="push.example.com" type="set">
    <command xmlns="http://jabber.org/protocol/commands" action="execute" node="register-push-fcm">
        <x xmlns="jabber:x:data" type="submit">
          <field var="token">
            <value>dPrh685pTdGns_MHsu1I-b:APA91bGwfwGthGPxE2aUJ5o-pyn1eMzV0WPqFulpyYo20xOEy7efh8soyJpcCuibleBGjCaRDRgjl6vSYNwDDE7pq0lfKOzubfUvCrvKvLMN4uRLEY373L11sCKqHeOf-_Qn3eooeOge</value>
          </field>
          <field var="device-id">
            <value>0ab43fb78f92ba10</value>
          </field>
        </x>
    </command>
</iq>
<iq from="push.example.com" id="x20" to="[email protected]/mobile" type="result">
    <command xmlns="http://jabber.org/protocol/commands" action="complete" node="register-push-fcm">
        <x xmlns="jabber:x:data" type="form">
            <field type="text-single" var="node">
                <value>KmDtdKoUTiGr</value>
            </field>
            <field type="text-single" var="secret">
                <value>FBfIl4qflMTDKn6CYPxXJHyH</value>
            </field>
        </x>
    </command>
</iq>

Enabling Notifications

  • After registering with the push server, Client sends the node ID and the jid of the app server (push.example.com) to the user's server.
<iq type='set' id='x42'>
  <enable xmlns='urn:xmpp:push:0' jid='push.example.com' node='KmDtdKoUTiGr'>
    <x xmlns='jabber:x:data' type='submit'>
      <field var='FORM_TYPE'><value>http://jabber.org/protocol/pubsub#publish-options</value></field>
      <field var='secret'><value>FBfIl4qflMTDKn6CYPxXJHyH</value></field>
    </x>
  </enable>
</iq>

Note: To support sandbox devices in iOS, you should provide the <field var="sandbox"><value>true</value></field> in publish options.

Example:

<iq type='set' id='x42'>
  <enable xmlns='urn:xmpp:push:0' jid='push.example.com' node='37Ni514izxHG'>
    <x xmlns='jabber:x:data' type='submit'>
      <field var='FORM_TYPE'><value>http://jabber.org/protocol/pubsub#publish-options</value></field>
      <field var='secret'><value>Zt9z9wOtAUOSYCtYC7a5OORa</value></field>
      <field var="sandbox"><value>true</value></field>
    </x>
  </enable>
</iq>

More info can be found in XEP-0357 Section 5

Disabling Notifications

<iq type='set' id='x97'>
  <disable xmlns='urn:xmpp:push:0' jid='push.example.com' node='37Ni514izxHG' />
</iq>

More info can be found in XEP-0357 Section 6

Publishing Notifications

It can be found in XEP-0357 Section 7.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.