Skip to content

A replacement API for AirNotifier Moodle Plugin that connects directly to Firebase and other Push Notification Providers

License

Notifications You must be signed in to change notification settings

egeniq/airnotifier-moodle-bridge

 
 

Repository files navigation

AirNotifier Moodle Plugin Bridge

A replacement API for AirNotifier server for the AirNotifier Moodle Plugin that connects directly to Firebase, or others Push Notification Providers. This was made since newer versions of AirNotifier seems to be not working with the Moodle Plugin due to usage of old apis. This server implements all needed endpoints and acts as a middleware between Moodle AirNotifier Plugin and Push Notification Providers.

Installation

This server uses NodeJS instead of Python (Used by AirNotifier). Be sure to have NodeJS version >= 10 installed.

Also install Firebase SDK to your platform in order to obtain FCM Token or the other Client SDKs needed.

Configure

You would need to get the configuration from your firebase console or other adapters. Check the index.js file for each adapter configuration.

Also the headers X-An-App-Key and X-An-App-Name should be set in both server config and moodle plugin settings. Is recommended a random value using npm run uuid script for X-An-App-Key.

Be sure to set the correct server address and port in your Moodle Plugin Settings. (Beware of trailing slashes in the server address).

Check that you can interact with the server. The root endpoint should return a json with the version number.

Usage

  • Start the server with npm start.

  • Send FCM Token. Not the native token.

  • You can also use npm run forever to init a background process.

#!/bin/sh

forever start --minUptime 1000 --spinSleepTime 1000  -o out.log -e err.log index.js

Example token registration

This is how you can send from your Firebase SDK instance to your Moodle server. You have to send the FCM Token in the pushid param.

Note: Contains Invalid token values for security purposes.

https://my.moodle.site/webservice/rest/server.php?wstoken=skkd1m1m3123km32kkckas3&appid=com.myapp.seed&name=Ninja's%20iPhone&model=iPhone&platform=ios&version=10.3.2&pushid=dWZfI--pSUXygaBKRVAslm:APA91bE-GiFkSCg-r1z-XoOVm-cPoXLd9dbhs3bZjPJb2t8GCCVFzrBE8UmoJSsjGbN2MhRq1MllOfFB_kOlZ1_3jvHaSrqrn7plxH1&uuid=12311-8EC8-4A93-A6C231228&wsfunction=core_user_add_user_device&moodlewsrestformat=json

Example notification

You can configure this request in Postman or similar HTTP client.

Headers

  • X-AN-APP-KEY: A1159649-4DE0-4449-A8CF-ED0922312BF2

  • X-AN-APP-NAME: myapp

Body

  • format: x-www-form-urlencoded

  • token: <FCM Token>

  • extra[smallmessage]: An small excerpt of the message

  • extra[sitefullname]: Who is sending the message

  • extra[contexturl]: Where to send the user after notification click

Sponsor Fused

This code was made possible thanks to the folks at Fused. Fused merges decades of performance experience with leading-edge technology.

Made by Ninjas.cl

This was developed (with :love:) by Ninjas.cl.

LICENSE

MIT

About

A replacement API for AirNotifier Moodle Plugin that connects directly to Firebase and other Push Notification Providers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%