@consento/notification-server
A expo based notification implementation for Consento. Both server & client code.
Last updated a month ago by leichtgewicht .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @consento/notification-server 
SYNC missed versions from official npm registry.

@consento/notification-server

The @consento/notification-server is a expo based notification implementation for Consento. It consists of two parts: The Server & The Client.

Why?

Consento is supposed to run as decentralized as possible. Initially the decentralization of the notification system is not just a lot of work (please contact us if you want to support implement this) but also a risk in the current development phase. For that reason we are using Expo Push Notifications in the current version of Consento.

The Server

Rationale

Expo has one push-token per device/app! If this were to be directly shared with other devices, they would be able to spam/send the device without the possibility to for the other device to stop listening to these notifications.

The centralized server also open the possibility to later implement other notification systems that run on the same system. i.e. a decentralized system or desktop system that has different requirements.

Start the server

You can start the server using:

npx @consento/notification-server

It will log any messages as json to stdout.

You can change the port using env PORT=8080 npx @consento/notification-server

Storage

The server persists the current state in a HyperDB instance. This system could in future be used to distribute the state over multiple instances of the notification server running on different devices.

The Client

The client implements the INotificationTransport interface of @consento/api. It can be setup as follows:

const { ExpoTransport } = require('@consento/notification-server')
const { setup } = require('@consento/api')
const { sodium } = require('@consento/crypto/core/sodium')
const * as Notifications = require('expo-notifications')

const api = setup({
  cryptoCore: sodium,
  notificationTransport: new ExpoTransport({
    address: 'https://server.com/api', // insert the root of the running notification-server here
    getToken: async () => Notifications.getExpoPushTokenAsync() // Read more https://docs.expo.io/versions/latest/sdk/notifications/
  })
})

With this API you can send/receive notifications like this:

const { receiver, sender } = api.crypto.createReceiver()

api.notifications.on('message', (receiver/*: IReceiver*/, message) => {
  console.log('hello world')
})
api.notifications.subscribe(receiver) // Usually this happens on a different device
api.notifications.send(sender, 'Hello World')

License

MIT

Current Tags

  • 0.1.21                                ...           latest (a month ago)

40 Versions

  • 0.1.21                                ...           a month ago
  • 0.1.20                                ...           a month ago
  • 0.1.19                                ...           2 months ago
  • 0.1.18                                ...           3 months ago
  • 0.1.17                                ...           3 months ago
  • 0.1.16                                ...           3 months ago
  • 0.1.15                                ...           4 months ago
  • 0.1.14                                ...           4 months ago
  • 0.1.13                                ...           4 months ago
  • 0.1.12                                ...           4 months ago
  • 0.1.11                                ...           4 months ago
  • 0.1.10                                ...           4 months ago
  • 0.1.9                                ...           4 months ago
  • 0.1.8                                ...           4 months ago
  • 0.1.7                                ...           4 months ago
  • 0.1.6                                ...           4 months ago
  • 0.1.5                                ...           4 months ago
  • 0.1.4                                ...           5 months ago
  • 0.1.3                                ...           6 months ago
  • 0.1.2                                ...           6 months ago
  • 0.1.1                                ...           6 months ago
  • 0.1.0                                ...           7 months ago
  • 0.0.19                                ...           10 months ago
  • 0.0.18                                ...           10 months ago
  • 0.0.17                                ...           10 months ago
  • 0.0.16                                ...           10 months ago
  • 0.0.15                                ...           10 months ago
  • 0.0.14                                ...           a year ago
  • 0.0.13                                ...           a year ago
  • 0.0.12                                ...           a year ago
  • 0.0.11                                ...           a year ago
  • 0.0.10                                ...           a year ago
  • 0.0.9                                ...           a year ago
  • 0.0.8                                ...           a year ago
  • 0.0.7                                ...           a year ago
  • 0.0.6                                ...           a year ago
  • 0.0.4                                ...           a year ago
  • 0.0.3                                ...           a year ago
  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
Downloads
Today 0
This Week 0
This Month 40
Last Day 0
Last Week 0
Last Month 66
Dependencies (26)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |