Skip to content

Node.js push notification server which is compatible with PubSubHubbub protocol.

Notifications You must be signed in to change notification settings

xfrocks/node_pubhubsubbub_pushserver

Repository files navigation

WebSub Push Server

Build Status Coverage Status

Node.js push notification server which is compatible with WebSub protocol.

  1. Mobile application (App) that wants to receive push notifications from WebSub Publisher (Publisher) may register itself with this Push Server (Server).
  2. Server will subscribe on behalf of App with Publisher.
  3. When Publisher publishes something, Server will forward the information to App via one of the supported push services.

Deployment

Notes:

  • By default, there'll be 1 worker to push notifications by npm start. It is possible to have multiple separated instances of workers by using npm run worker. In that case, it's recommended to disable the default one by setting env var CONFIG_PUSH_QUEUE_WORKER=false.

Docker Compose

  app:
    image: xfrocks/pushserver
    environment:
      - CONFIG_WEB_USERNAME=admin
      - CONFIG_WEB_PASSWORD=123456
      - MONGO_URI=mongodb://mongo/pushserver
      - REDIS_URL=http://redis:6379
    depends_on:
      - mongo
      - redis
    ports:
      - "80:18080"

See docker-compose.yml file for full example. Please note that the yml is for development purposes, it is not secure.

Heroku

Deploy

Usage

Subscription

Send a POST request to /subscribe:

  • hub_uri (required)
  • oauth_client_id (required)
  • oauth_token (required)
  • device_type (required): see Supported Services for explanation
  • device_id (required): see Supported Services for explanation
  • extra_data (optional)

Supported Services

Apple Push Notification

via argon/node-apn

Project configuration at /admin/projects/apn:

  • bundle_id (required): The iOS application Bundle ID
  • token, an array of...
  • key (required): The provider token key in plaintext
  • keyId (required): The ID of the key issued by Apple
  • teamId (required): The team ID associated with the provider token
  • Please note that if you don't configure provider token, the RSA cert/key pair is required
  • production (optional): 1 for production, 0 for sandbox

App that wants to receive via APN must include these parameters during subscription:

  • device_type = ios
  • device_id = APN Device Token
  • extra_data[package] = Bundle ID

Firebase Cloud Messaging

via firebase-admin (the official SDK)

Project configuration at /admin/projects/fcm, parameters:

  • project_id (required): The Google project ID
  • client_email (required)
  • private_key (required)

App that wants to receive via FCM must include these parameters during subscription:

  • device_type = firebase
  • device_id = FCM Registration Token
  • extra_data[project] = Project ID

By default, the server will push data messages...

  • extra_data[notification] if specified, notification messages will be pushed instead
  • extra_data[click_action] the action associated with a user click on the notification. Corresponds to category in the APNs payload.

Google Cloud Messaging

via ToothlessGear/node-gcm

Project configuration at /admin/projects/gcm, parameters:

  • package_id (required): The Android application package ID
  • api_key (required): The API key for GCM (obtain via Google Developer Console)

App that wants to receive via GCM must include theses parameters during subscription:

  • device_type = android
  • device_id = GCM Registration Token
  • extra_data[package] = Package ID

Huawei Push Kit

Project configuration at /admin/projects/hms, parameters:

  • app_id (required)
  • app_secret (required)

App that wants to receive via FCM must include these parameters during subscription:

  • device_type = huawei
  • device_id = HMS Token
  • extra_data[app] = App ID

Optional extra_data params:

  • badge_class, badge_with_convo: control whether to include badge in pushes
  • click_action: android.notification.click_action.action will be set to this value (type=1)
  • intent_prefix: android.notification.click_action.intent will be set with this prefix and content_type, convo_id or notification_id (if available)
  • notification_default_title: required to receive notification for XenForo alert because HMS requires notification title

Windows Push Notification

via tjanczuk/wns

Project configuration at /admin/projects/wns, parameters:

  • package_id (required): The Windows application package ID
  • client_id (required): The Windows client ID
  • client_secret (required): The Windows client secret

App that wants to receive via WNS must include theses parameters during subscription:

  • device_type = windows
  • device_id = Device ID
  • extra_data[package] = Package ID
  • extra_data[channel_uri] = Channel URI