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.
This server uses NodeJS instead of Python (Used by AirNotifier). Be sure to have NodeJS version >= 10 installed.
-
$ git clone https://github.com/NinjasCL/airnotifier-moodle-bridge
. -
$ cd airnotifier-moodle-bridge
. -
$ npm install
. -
$ npm install -g forever
.
Also install Firebase SDK to your platform in order to obtain FCM Token or the other Client SDKs needed.
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.
-
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
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
You can configure this request in Postman or similar HTTP client.